App crashes with FORMAT_UPGRADE_REQUIRED while using Realm 7.0.0
We have been using Realm from the past year, We recently upgraded the application from V6.1.0 to V7.0.0, post this upgrade we are witnessing the crash mentioned, we are using Kotlin for application development with Realm java and lastly, we have enabled DB encryption
Process: com.com.myapp.Application.qa, PID: 31558
java.lang.RuntimeException: Unable to create application com.myapp.Application: io.realm.exceptions.RealmFileException: Opening Realm files of format version 0 is not supported by this version of Realm (Database has an unsupported version and cannot be upgraded
Exception backtrace:
(/data/data/com.myapp.Application:/files/myapp.realm) in /Users/cm/Realm/realm-java-release/realm/realm-library/src/main/cpp/io_realm_internal_OsSharedRealm.cpp line 107 Kind: FORMAT_UPGRADE_REQUIRED.
at io.realm.internal.OsSharedRealm.nativeGetSharedRealm(Native Method)
at io.realm.internal.OsSharedRealm.
How are you opening the Realm?
DB configuration :
RealmLivedataWrapper.init(context)
val config = RealmConfiguration.Builder()
.name(BuildConfig.REALM_FILE_NAME)
.modules(Realm.getDefaultModule(), DataRealmModules())
.encryptionKey(StorageKeyUtils.getKey(sharedPreferences, context))
.schemaVersion(BuildConfig.REALM_SCHEMA_VERSION)
.migration(DbMigration())
.build()
Realm.setDefaultConfiguration(config)
realmLivedataWrapper = RealmLivedataWrapper.Builder()
.setRealmConfiguration(config)
.build()
While navigating between the modules its crashing at val realm: Realm = Realm.getDefaultInstance()
Weird. The error message seems to indicate that you are opening an older already existing file. Is that the case?
It's crashing while navigating from one module to another after some modifications. We have used Realm v6.1.0. This issue is observed when upgraded to v7.0.0 .
The same scenario is working fine with Realm v6.1.0
Will there be any issue if we use following method in 7.0.0
val realm: Realm = Realm.getDefaultInstance() realm.sharedRealm.refresh() try { realm.executeTransaction { realmInstance -> realmInstance.copyToRealmOrUpdate(dataObjects) } } catch (ex: Exception) { Log.d("DOWNLOAD_ERROR", "storeToLocal DB store EXCEPTION") Log.d(this::class.java.simpleName, ex.message) } finally { realm.refreshAndClose() }
Hi.Any update on the above issue? We are facing the above crash with above error in multiple places .
I have noticed this error too. We have only upgraded realm version and did not touch schema itself. Mostly it occurs on Android 10 devices. Most popular devices which failed to upgrade:
Samsung Galaxy A70
Xiaomi Mi9 SE
Nokia 5
Other devices seemed to work fine, but this is quite critical.
Exactly the same issue on our side, reproduced on my Pixel 3 on Android 9.
@ganfra Can you share how to reproduce? If you want to keep it private you can email me at [email protected]
If you are brave enough you can test it on our open-source project: https://github.com/vector-im/riotX-android Updating realm to 7.0.0, then after some initial launches it will crash with this issue. (Also, not related at all, but we are having massive performance issues when db is getting big)
So I created a test account where you will be able to reproduce the error: Login: realm7 Password: realm7.0help
You should use the develop branch.
So here is how to reproduce
- compile the app with realm 6.1.0 (in the matrix-sdk-android gradle file).
- launch and log in with given credentials.
- Compile the app with realm 7.0.0
- Relaunch the app, use the app a bit.
- kill the app and relaunch => it should crash. If not, kill and relaunch until it crashes
Tell me if you need more information :)
@cmelchior : any chance you could look at it?
@ganfra Thank you for the project. I am able to reproduce the problem. We are looking into it.
A few things ruled out:
- It isn't a wrong encryption key causing this issue or lack of key completely.
Did you have any lead on what could be wrong?
@cmelchior Would appreciate any update on this. Unfortunately, we too face this issue after upgrading from v6.1.0 to v7.0.0. It has resulted into hundreds of crashes reported in Firebase in barely few hours.
@patelnishantk Unfortunately we still don't have a root cause for this.
We are experiencing the same issue with a single client.
@cmelchior We are going to extract the user database and analyse it to see if it's the realm running in the device that cannot open it or if the realm file is corrupted.
We got the Realm file and when opening it on Realm Studio, we get the very same error:
