Realm.init()无法解析方法init无法在Application onCreate中工作?(Realm.init() cannot resolve method init not workin

系统教程 行业动态 更新时间:2024-06-14 16:58:00
Realm.init()无法解析方法init无法在Application onCreate中工作?(Realm.init() cannot resolve method init not working in Application onCreate?)

无法在Realm上调用init()方法。 我有什么想法我做错了吗?

我在build.gradle(项目)中添加了依赖项:

buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.3.1' classpath "io.realm:realm-gradle-plugin:3.2.0" } }

并在build.gradle(app)中应用了该插件

apply plugin: 'com.android.application' apply plugin: 'realm-android'

Can't call init() method on Realm. Any ideas what I'm doing wrong?

I have added the dependency in my build.gradle(project):

buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.3.1' classpath "io.realm:realm-gradle-plugin:3.2.0" } }

and applied the plugin in the build.gradle(app)

apply plugin: 'com.android.application' apply plugin: 'realm-android'

最满意答案

这似乎是Android Studio索引系统的一个缺陷 。 试试下一个解决方

同步gradle文件 在此处输入图像描述 使IDE索引无效并重新启动 在此处输入图像描述

最后的假设 - 移动io.realm:realm-gradle-plugin:3.2.0依赖项目build.gradle文件到build.gradle从app并定义自己的buildscript部分:

buildscript { repositories { jcenter() } dependencies { classpath 'io.realm:realm-gradle-plugin:3.2.0' } }

项目的自动生成的build.gradle包含有关此内容的下一个注释:

//注意:不要在此处放置应用程序依赖项; 他们属于 //在单个模块build.gradle文件中

It seems like a lagg at Android Studio indexes system. Try next solutions:

Sync gradle files enter image description here Invalidate IDE indexes and restart enter image description here

And the last assumption - move io.realm:realm-gradle-plugin:3.2.0 dependency from project build.gradle file to build.gradle from app and define own buildscript section:

buildscript { repositories { jcenter() } dependencies { classpath 'io.realm:realm-gradle-plugin:3.2.0' } }

Autogenerated build.gradle for project contains next note about this:

// NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files

更多推荐

本文发布于:2023-04-14 05:19:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/8aaece21533a42a94199da34c83713a0.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:方法   工作   Application   init   Realm

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!