我是 android 新手,我在我的 APP 中使用了领域,但当时我没有指定 schemaversion,现在当我想升级应用程序并实施迁移时。
以前,我是这样做的,
Realm.init(getApplicationContext());
RealmConfiguration realmConfiguration =
new RealmConfiguration.Builder().build();
realm = Realm.getInstance(realmConfiguration);
现在,
Realm.init(getApplicationContext());
RealmConfiguration realmConfiguration =
new RealmConfiguration.Builder().schemaVersion(1).migration(new Migration()).build();
realm = Realm.getInstance(realmConfiguration);
而且,我收到了这个错误。
java.lang.IllegalArgumentException: Configurations cannot be different if used to open the same file.
Cached configuration:
realmDirectory: /data/user/0/in.avanti_app.student_companion.debug/files
realmFileName : default.realm
canonicalPath: /data/data/in.avanti_app.student_companion.debug/files/default.realm
key: [length: 0]
schemaVersion: 1
migration: in.avanti_app.student_companion.realmClasses.Migration@25
deleteRealmIfMigrationNeeded: false
durability: FULL
schemaMediator: io.realm.DefaultRealmModuleMediator@793ec9a4
New configuration:
realmDirectory: /data/user/0/in.avanti_app.student_companion.debug/files
realmFileName : default.realm
canonicalPath: /data/data/in.avanti_app.student_companion.debug/files/default.realm
key: [length: 0]
schemaVersion: 0
migration: null
deleteRealmIfMigrationNeeded: false
durability: FULL
schemaMediator: io.realm.DefaultRealmModuleMediator@793ec9a4
我还覆盖了 Migration 类中的 hasCode 和 equals。