question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Realm Migration ValidateConfiguration error (Configurations cannot be different if used to open the same file).

See original GitHub issue

Goal

Realm Migration from schema version 1 to 2.

Expected Results

Migrate unsuccesful.

Actual Results

java.lang.IllegalArgumentException: Configurations cannot be different if used to open the same file. Cached configuration: realmDirectory: /data/data/in.novopay.leadr/files realmFileName : loansappsdk_db.realm canonicalPath: /data/data/in.novopay.leadr/files/loansappsdk_db.realm key: [length: 0] schemaVersion: 2 migration: com.khoslalabs.loansappsdk.common.RealmMigration@25 deleteRealmIfMigrationNeeded: false durability: FULL schemaMediator: io.realm.LoansAppSDKRealmModuleMediator@1d3477e8 readOnly: false New configuration: realmDirectory: /data/data/in.novopay.leadr/files realmFileName : loansappsdk_db.realm canonicalPath: /data/data/in.novopay.leadr/files/loansappsdk_db.realm key: [length: 0] schemaVersion: 1 migration: null deleteRealmIfMigrationNeeded: false durability: FULL schemaMediator: io.realm.LoansAppSDKRealmModuleMediator@1d3477e8 readOnly: false at io.realm.RealmCache.validateConfiguration(RealmCache.java:461) at io.realm.RealmCache.doCreateRealmOrGetFromCache(RealmCache.java:337) at io.realm.RealmCache.createRealmOrGetFromCache(RealmCache.java:284) at io.realm.Realm.getInstance(Realm.java:299) at com.khoslalabs.loansappsdk.common.CrashHandler.initRealm(CrashHandler.java:71) at com.khoslalabs.loansappsdk.common.CrashHandler.<init>(CrashHandler.java:57) at com.khoslalabs.loansappsdk.LoansAppSDK.<init>(LoansAppSDK.java:131) at com.khoslalabs.loansappsdk.LoansAppSDK.<init>(LoansAppSDK.java:45) at com.khoslalabs.loansappsdk.LoansAppSDK$Builder.build(LoansAppSDK.java:431) at com.khoslalabs.loansappsdk.LoansAppSDK.with(LoansAppSDK.java:194) at com.khoslalabs.mpinregistrationlibrary.AgentLoginActivity.initMlSdk(AgentLoginActivity.java:270) at com.khoslalabs.mpinregistrationlibrary.AgentLoginActivity.access$1500(AgentLoginActivity.java:95) at com.khoslalabs.mpinregistrationlibrary.AgentLoginActivity$12.onClick(AgentLoginActivity.java:927) at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:178) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:145) at android.app.ActivityThread.main(ActivityThread.java:7007) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)

Steps & Code to Reproduce

Tired normal debugging the above exception arises.

Code Sample

This is a library project*


public void migrate(DynamicRealm realm, long oldVersion, long newVersion) {
        RealmSchema realmObjectSchema = realm.getSchema();
        if(oldVersion == 1L) {
            RealmObjectSchema onetimeapp = realmObjectSchema.get("OneTimeApp");
            onetimeapp.removeField("uuid").removeField("customerId").removeField("partnerId").removeField("activity_at").removeField("uploaded_at");
            RealmObjectSchema onetimeappdata = realmObjectSchema.get("OneTimeAppData");
            onetimeappdata.removeField("uuid").removeField("customerId").removeField("partnerId").removeField("activity_at").removeField("uploaded_at");
            RealmObjectSchema onetimecall = realmObjectSchema.get("OneTimeCall");
            onetimecall.removeField("uuid").removeField("customerId").removeField("partnerId").removeField("activity_at").removeField("uploaded_at");
            RealmObjectSchema onetimecontact = realmObjectSchema.get("OneTimeContact");
            onetimecontact.removeField("uuid").removeField("customerId").removeField("partnerId").removeField("activity_at").removeField("uploaded_at");
            RealmObjectSchema onetimephone = realmObjectSchema.get("OneTimePhone");
            onetimephone.removeField("uuid").removeField("customerId").removeField("partnerId").removeField("activity_at").removeField("uploaded_at").addField("appVersion", String.class, new FieldAttribute[]{FieldAttribute.REQUIRED}).addField("isDualSim", Boolean.class, new FieldAttribute[]{FieldAttribute.REQUIRED});
            RealmObjectSchema onetimesms = realmObjectSchema.get("OneTimeSms");
            onetimesms.removeField("uuid").removeField("customerId").removeField("partnerId").removeField("activity_at").removeField("uploaded_at");
            RealmObjectSchema phone = realmObjectSchema.get("Phone");
            phone.addField("isDualSim", Boolean.class, new FieldAttribute[]{FieldAttribute.REQUIRED});
            ++oldVersion;
        }

    }

Realm realm = Realm.getInstance(realmConfiguration);

Schema Version 1 Realm Configuration:
RealmConfiguration realmConfiguration = new RealmConfiguration.Builder()
                .name("loansappsdk_db.realm")
                .modules(new LoansAppSDKRealmModule())
                .schemaVersion(1)
                .build();
        return realmConfiguration;

Schema Version 2 Realm Configuration:
RealmConfiguration realmConfiguration = new RealmConfiguration.Builder()
                .name("loansappsdk_db.realm")
                .modules(new LoansAppSDKRealmModule())
                .schemaVersion(2)
                .migration(new RealmMigration())
                .build();
        return realmConfiguration;


Version of Realm and tooling

Realm version(s): 3.4.0

Realm sync feature enabled: yes

Android Studio version: 3.0

Which Android version and device: 5.1.1 & Samsung j3

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
vamshikhoslalabscommented, Nov 22, 2017

@Zhuinden Added this

@Override public int hashCode() { return 37; }

@Override public boolean equals(Object o) { return (o instanceof RealmMigration); }

0reactions
cmelchiorcommented, Nov 27, 2017

@vamshikhoslalabs I assume the above solved your question. If not, feel free to reopen.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Realm crashes at first call. Configurations cannot be different if ...
I just went with the deleteRealmIfMigrationNeeded and it worked great. I wanted the app to try to go on, but if migration is...
Read more >
Realm: Create reactive mobile apps in a fraction of the time
When a synced Realm requiring migration is opened, the Realm file will be copied to a backup location and then deleted so that...
Read more >
Migrating Secure Firewall ASA to Threat Defense with ... - Cisco
ASA configuration lines with errors, lists the ASA CLIs that the Secure Firewall migration tool cannot recognize; this blocks migration. If ...
Read more >
Server Developer Guide - Keycloak
Obtain an access token for the user in the realm master with username ... There are a list of properties that can be...
Read more >
Realmのマイグレーションで Configurations cannot be ...
Or you can add the migration code to the configuration. ... で Configurations cannot be different if used to open the same file....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found