Unable to open a realm at path
See original GitHub issueHi! Fabric is reporting a crash on one of our apps which is affecting a pretty high number of users and I have not been able to reproduce it or find a fix online. Has one got any tips on how I could go about fixing this issuse?
I have disabled automatic backup on the realm files but that didn’t happen to fix things.
Actual Results
Fatal Exception: io.realm.exceptions.RealmFileException: Unable to open a realm at path '/data/data/com.pitchero.ph/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.pitchero.ph/files/default.realm) in /Users/Nabil/Dev/realm/master/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_OsSharedRealm.cpp line 101 at io.realm.internal.OsSharedRealm.nativeGetSharedRealm(OsSharedRealm.java) at io.realm.internal.OsSharedRealm.<init>(OsSharedRealm.java:171) at io.realm.internal.OsSharedRealm.getInstance(OsSharedRealm.java:241) at io.realm.internal.OsSharedRealm.getInstance(OsSharedRealm.java:231) at io.realm.RealmCache.doCreateRealmOrGetFromCache(RealmCache.java:319) at io.realm.RealmCache.createRealmOrGetFromCache(RealmCache.java:282) at io.realm.Realm.getDefaultInstance(Realm.java:343) at com.pitchero.ph.utils.AppUtils.logout(AppUtils.java:29) at com.pitchero.ph.MainActivity$4.run(MainActivity.java:365) at android.app.Activity.runOnUiThread(Activity.java:5907) at com.pitchero.ph.MainActivity.goBackToIntroActivity(MainActivity.java:362) at com.pitchero.ph.MainActivity.access$300(MainActivity.java:73) at com.pitchero.ph.MainActivity$1.run(MainActivity.java:242) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:241) at android.app.ActivityThread.main(ActivityThread.java:6274) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Steps & Code to Reproduce
I have not been able to reproduce the error, it’s something that is picked up by Fabric. I have recently disabled automatic back up for the realm files and I was hoping this will fix this error as well but it seems to still come up.
Code Sample
Version of Realm and tooling
Realm version(s): 5.0.1
Realm sync feature enabled: no
Android Studio version: 3.1.2
Which Android version and device: 5,6,7,8 - (unknown devices) - data from Fabric
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (4 by maintainers)
Now is a good time for me to chime in and hope that this will gain some attention internally, as I apparently don’t have the C++ knowledge to modify the core: https://github.com/realm/realm-core/issues/2968
Hi @tudorsirbu Unfortunately, there isn’t much we can do about this unless it can be reproduced. If you are able to send a Realm file that fails to open this way then we can investigate what is wrong with it, which might give some clues as to why it is happening.
But yes, my best guess is that something is that something other than Realm is manipulating the file.
With regards to a possible fix, then I don’t know what the Realm contains. If it is just a network cache, then you can catch that exception, delete the file and re-open the Realm. It would obviously mean users would have to download the data again, but at least it wouldn’t crash their app.