realm-java: Incompatible histories. Expected a Realm with no or in-realm history

We get the following exception when trying to open the default realm:

FATAL EXCEPTION: main
Process: com.anghami, PID: 8169
java.lang.RuntimeException: Unable to create application com.anghami.AnghamiApplication: io.realm.exceptions.RealmFileException: Unable to open a realm at path '/data/data/com.anghami/files/default.realm': Incompatible histories. Expected a Realm with no or in-realm history. (Incompatible histories. Expected a Realm with no or in-realm history) (/data/data/com.anghami/files/default.realm) in /home/cc/repo/realm/release/realm/realm-library/src/main/cpp/io_realm_internal_SharedRealm.cpp line 252 Kind: ACCESS_ERROR.
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5973)
    at android.app.ActivityThread.-wrap3(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1710)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6776)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
 Caused by: io.realm.exceptions.RealmFileException: Unable to open a realm at path '/data/data/com.anghami/files/default.realm': Incompatible histories. Expected a Realm with no or in-realm history. (Incompatible histories. Expected a Realm with no or in-realm history) (/data/data/com.anghami/files/default.realm) in /home/cc/repo/realm/release/realm/realm-library/src/main/cpp/io_realm_internal_SharedRealm.cpp line 252 Kind: ACCESS_ERROR.
    at io.realm.internal.SharedRealm.nativeGetSharedRealm(Native Method)
    at io.realm.internal.SharedRealm.<init>(SharedRealm.java:186)
    at io.realm.internal.SharedRealm.getInstance(SharedRealm.java:239)
    at io.realm.internal.SharedRealm.getInstance(SharedRealm.java:202)
    at io.realm.RealmCache.doCreateRealmOrGetFromCache(RealmCache.java:298)
    at io.realm.RealmCache.createRealmOrGetFromCache(RealmCache.java:284)
    at io.realm.Realm.getDefaultInstance(Realm.java:281)
    at com.anghami.data.local.RealmHelper.call(RealmHelper.java:155)
    at com.anghami.data.local.RealmHelper.call(RealmHelper.java:148)
    at com.anghami.config.RealmConfig.initialize(RealmConfig.java:76)
    at com.anghami.AnghamiApplication.onCreate(AnghamiApplication.java:69)
    at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1032)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5970)
    at android.app.ActivityThread.-wrap3(ActivityThread.java) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1710) 
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:154) 
    at android.app.ActivityThread.main(ActivityThread.java:6776) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)

This realm doesn’t use encryption(and we’ve never used it on the default realm) but another realm in the same app does use encryption.

I will attach the actual realm file that’s causing this blowup in a bit

Version of Realm and tooling

Realm version(s): 3.5.0

Realm sync feature enabled: no

Android Studio version: Android Studio 3.0 beta 2

Which Android version and device: Android 7.0 running on a Samsung S8+

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 22 (9 by maintainers)

Most upvoted comments

Version 10?

EDIT: oh, 10.0.0 (2020-10-15), congrats!

No not possible. Up until I got my hands on the phone, the version of the app installed was non debuggable(installed from store beta) and the phone isn’t rooted

On Thu, Aug 31, 2017 at 7:27 AM Chen Mulong notifications@github.com wrote:

Would it be possible that the user is actually using adb pull and push back the default.realm file? (like pull the Realm file, check with the Realm browser, change some something then push it back while the app is still running). change the file through any other way without Realm involved will damage the Realm file.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/realm/realm-java/issues/5175#issuecomment-326186241, or mute the thread https://github.com/notifications/unsubscribe-auth/ABNP7uq-Ieu7MRkSfe4BxEBTXlUpPr2bks5sdjYjgaJpZM4PHDXY .