将领域版本从 0.82.1 更改为 0.87.5 后,我收到此错误。
FATAL EXCEPTION: main Process: com.xxxxx.consumer, PID: 8633
java.lang.RuntimeException: Unable to create applicationcom.gemba.consumer.realm.AppInstance:
java.lang.IllegalArgumentException: Configurations cannot be different if used to open the same file.
Cached configuration:
realmFolder: /data/user/0/com.xxxx.consumer/files
realmFileName : default.realm
canonicalPath: /data/data/com.xxxx.consumer/files/default.realm
key: [length: 0]
schemaVersion: 0
migration: null
deleteRealmIfMigrationNeeded: true
durability: FULL
schemaMediator: io.realm.DefaultRealmModuleMediator@b40b99c9
我的领域管理器类是这个公共最终类 RealmManager {
public static RealmManager realmManager;
public static RealmConfiguration realmConfig;
public static Realm realm;
public static WorkerThread workerThread;
public static Context appContext;
public static RealmManager getInstance(Context context) {
if (realmManager == null) {
realmManager = new RealmManager();
getRealmConfig(context);
realm = Realm.getInstance(realmConfig);
workerThread = new WorkerThread(context);
appContext = context;
}
return realmManager;
}
public static RealmConfiguration getRealmConfig(Context context) {
if (realmConfig == null) {
realmConfig = new RealmConfiguration.Builder(context)
.deleteRealmIfMigrationNeeded()
.build();
}
return realmConfig;
}
我在应用程序类中像这样使用它。
RealmManager.getInstance(getApplicationContext());