在Kotlin Realm Extention中如何解决“功能不属于这个领域的模式的一部分”

我想用Kotlin使用Realm使用这个Kotlin Realm Extention库。 我已经添加mavenCentral()存储库并compile "com.github.vicpinm:krealmextensions:1.2.0"到app.gradle。

当我运行我的应用程序,我得到了这个错误: java.lang.IllegalArgumentException: Feature is not part of the schema for this Realm. Did you added realm-android plugin in your build.gradle java.lang.IllegalArgumentException: Feature is not part of the schema for this Realm. Did you added realm-android plugin in your build.gradle

我试图在app.gradle中添加apply: realm-android ,但它不工作(旁边我认为它应该从库内部调用)。 我还在我的Activity中添加了Realm.init(baseContext) ,因为查询操作需要它。

您的插件顺序需要

 apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' apply plugin: 'kotlin-kapt' apply plugin: 'realm-android'