【发布时间】:2017-01-26 15:44:51
【问题描述】:
我正在使用领域作为我的应用程序的数据库,并且我有模型 SessionModel:
public class SessionModel extends RealmObject {
private long id;
private int currentPomod;
private int state;
...getters\setters
}
当我尝试在数据库中创建新文档时:
Realm.init(this);
realm = Realm.getDefaultInstance();
realm.beginTransaction();
realm.copyToRealm(defSession);
我收到此错误:java.lang.IllegalArgumentException: SessionModel is not part of the schema for this Realm
我的顶级 gradle 文件包含以下依赖项:
...
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath "io.realm:realm-gradle-plugin:2.3.0"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
...
和应用此插件的应用程序 gradle 模块(在 build.gradle 模块应用程序文件的顶部):
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
...
即时运行已禁用。
【问题讨论】:
-
你使用 Kotlin 还是任何其他神奇的东西,可能是
apt或kapt?如果您没有android-apt,则应该自动应用annotationProcessor范围。 -
我不使用这些功能。
-
问题已解决。领域不使用在 gradle 中启用的 Jack 工具链。因此,当我从我的应用程序中删除 Jack 时,Realm 可以正常工作。我还添加了 Retrolambda 库而不是 Jack 来支持 lambda 表达式。
标签: java android gradle realm illegalargumentexception