无法在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 Invalidate IDE indexes and restartAnd 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
更多推荐
发布评论