realm-java: Illegal Argument Exception encountered when compressing a Realm file created by version 0.83.0
Hi peeps,
I am currently running into an IllegalArgumentException
indicating that the format of the Realm file is invalid when I am trying to call Realm.compactRealm(realmConfiguration...)
before I use the realm file.
I have a sample project to demonstrate the crash here: https://github.com/creativepsyco/sample-realm-crash/
Essentially I am trying to compact the realm file before it is ever used in the app.
Steps to reproduce:
- Clone the project from https://github.com/creativepsyco/sample-realm-crash/
- Compile and run. It will not crash because realm version is
0.82.2
- Now in
build.gradle
edit the version to0.83.0
- Compile and run the app.
- It crashes with the stack trace:
FATAL EXCEPTION: main
Process: mohitkanwal.com.examplerealm, PID: 28687
java.lang.RuntimeException: Unable to start activity
ComponentInfo{mohitkanwal.com.examplerealm/mohitkanwal.com.examplerealm.MainActivity}:\
java.lang.IllegalArgumentException: Illegal Argument: Invalid format of Realm file.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3119)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3218)
at android.app.ActivityThread.access$1000(ActivityThread.java:198)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1676)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6837)
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)
Caused by: java.lang.IllegalArgumentException: Illegal Argument: Invalid format of Realm file.
at io.realm.internal.SharedGroup.createNativeWithImplicitTransactions(Native Method)
at io.realm.internal.SharedGroup.<init>(SharedGroup.java:68)
at io.realm.internal.SharedGroupManager.<init>(SharedGroupManager.java:49)
at io.realm.BaseRealm.<init>(BaseRealm.java:87)
at io.realm.Realm.<init>(Realm.java:151)
at io.realm.Realm.createAndValidate(Realm.java:279)
at io.realm.Realm.create(Realm.java:247)
at io.realm.Realm.getInstance(Realm.java:219)
at mohitkanwal.com.examplerealm.ContactHelper.getMeARealmFile(ContactHelper.java:53)
at mohitkanwal.com.examplerealm.ContactHelper.getAllContacts(ContactHelper.java:64)
at mohitkanwal.com.examplerealm.MainActivity.onCreate(MainActivity.java:25)
at android.app.Activity.performCreate(Activity.java:6500)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1120)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3072)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3218)
Is the SharedGroupManager.compact()
implementation compatible with the new format of the Realm File? Right now it seems to be unusable with any Realm created by v0.83
or v0.82.2
Regards Mohit
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 21 (13 by maintainers)
Commits related to this issue
- Unit test to match #1581 — committed to realm/realm-java by deleted user 9 years ago
I tried to reproduce this issue at our end and it’s not crashing but it crashes in the play store version only on some devices.
Is this possible that if I use
deleteRealmIfMigrationIsNeeded()
andmigration()
methods at the same time while creating Realm configuration, it throws this exception “IllegalArgumentException: Illegal Argument: Invalid format of Realm file.”Also, if I add
name()
method to create a realm file, will it create a new Realm file with that name or it just renames the previous one. As I am not usingname()
method right now and Realm creates a file with a default name.Hope to hear from you soon. Thanks.