Invalid format of Realm file

484 views
Skip to first unread message

Sava Mikalački

unread,
Sep 13, 2015, 6:16:45 PM9/13/15
to Realm Java
Hey everyone!

I'm working on an app that uses Realm as a database. I've created and populated the database in a separate application and added that realm database file to my other project. So on start of this other project I copy the database and then use it in my new app (i copy it from raw folder of my new app). This worked on every device I had access to, even updating my old app with this new version (old app didnt have realm support) worked but I started receiving crashes from multiple users of my app and here is the crashlog:

java.lang.IllegalArgumentException: Illegal Argument: Invalid format of Realm file.
       at io.realm.internal.SharedGroup.createNativeWithImplicitTransactions(SharedGroup.java)
       at io.realm.internal.SharedGroup.(SharedGroup.java:60)
       at io.realm.Realm.(Realm.java:205)
       at io.realm.Realm.createAndValidate(Realm.java:594)
       at io.realm.Realm.create(Realm.java:564)
       at io.realm.Realm.getInstance(Realm.java:537)

Both projects I have, the one that generates the database file and the one that is actually using the database file are with 0.82.1 realm version. Can you help me out on this? I cant replicate this issue on my device but I have 10 users reporting me this crash... 

Kenneth Geisshirt

unread,
Sep 14, 2015, 2:36:24 AM9/14/15
to Sava Mikalački, realm...@googlegroups.com
Hey,

You don't mention encryption so I assume you don't encrypt your Realm file. Of course, a wrong key would make a Realm file look invalid.

You mention crashes due to an invalid Realm file. Does the app crash the first time it is launched?

You are welcome to send the Realm file to he...@realm.io so we can investigate.

Best,
Kenneth

--
Kenneth Geisshirt
Member of technical staff


--
You received this message because you are subscribed to the Google Groups "Realm Java" group.
To unsubscribe from this group and stop receiving emails from it, send an email to realm-java+...@googlegroups.com.
To post to this group, send email to realm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/realm-java/f1a06a85-4cf5-4e32-9c3a-bac0f1bfc9d8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



{#HS:120147859-1854#}

Ravi Vagadia

unread,
Sep 21, 2015, 1:10:45 PM9/21/15
to Realm Java, mikal...@gmail.com, he...@realm.io
Hi Kenneth,

I'm facing exactly the same issue, I'm using realmdb with encryption and have tested it in multiple Android devices with no issues.  I rolled it out to 5% of my users on PlayStore over weekend. From around 800 users it is affect 9 users, these users are using HTC One X,  HTC Desire 526GPlus &  Leveno S820.

Looks like it appears only on some device.

@Sava would it be possible for you to share device models on which your users are facing issue?

Crash logs are same as Sava posted.

Thanks

Sava Mikalački

unread,
Sep 21, 2015, 3:43:01 PM9/21/15
to Realm Java, mikal...@gmail.com, he...@realm.io
Hey Ravi

I had a short discussion with Kenneth regarding this topic so we included checks to see if there is sufficient space available in order to copy the database. We prevented crashing at this point but the app is still silently crashing on the same thing: Invalid file format. We did numerous tests with various devices and available memory but couldnt reproduce the problem. The only time we could reproduce the problem was if we just open the realm file in a text editor, play around with its contents and just save it. We also added checks to be sure the file copy operation goes smooth and in fact it does, we dont get any crashes because of file copy operation. I would really love to continue using realm but this kind of thing raises concerns. 

@Ravi, here are some of devices we have crashing: Samsung SM T235, Samsung GT I9192, Sony C6603, LG Nexus 5... We couldnt find a pattern within devices or Android OS version. Let me know if you have some more info or I can help in some other way, but this seems unfixable to me at this point...

Ravi Vagadia

unread,
Sep 22, 2015, 1:18:15 PM9/22/15
to Realm Java, mikal...@gmail.com, he...@realm.io
Hi Sava,

Thanks for the information, I'm pushing out an update of my app this weekend. I'll put checksum verification to ensure that copy operation is proper and see if it fixes the issue. 

Let me know if you've got any other idea.

I'll post my findings here.

Thanks.

Sava Mikalački

unread,
Sep 22, 2015, 4:48:06 PM9/22/15
to Ravi Vagadia, Realm Java, Kenneth Geisshirt
Hi Ravi,

No problem, I am myself interested in figuring this out. So far, my conclusion is that this has nothing to do with realm but with the file copy operation. For some reason, file copy operation just produces corrupted file. I found several examples of the same behaviour with people copying smaller files and still ending up with corrupted files after copy. I played around with buffer size and output stream so we will check this in our next update. Please let me know how it goes with the checksum you will push in your update, we prevented our app from crashing but we are still receiving silent crashes. On our user base, number of affected users is not that significant, but this is starting to get on my nerves on a personal level :)
--
I have only two questions: How much and give it to me.

Łukasz Tokarski

unread,
Nov 10, 2015, 4:50:49 PM11/10/15
to Realm Java, rav...@gmail.com, he...@realm.io
Hi,

any updated on that problem? 3 weeks ago I have started to using Realm and I face the same problem.
Flow is: Parse a 50MB JSON to Realm DB - it works. Final realm db file is abt. 15MB. Then writeCopy (unencrypted) to the SDCard on the tablet (SGS Tab 2 10.1) to pull it onto Mac OS. Then add realm DB file to android res/raw folder. During the very first start of the app I copy res/raw info Context.getFilesDir()/default.realm, but when I try to: Realm.getInstance(Context) I get the same exception ("Illegal Argument: Invalid format of Realm file.).
I am able to open the same on Realm Browser available on Mac platform. I tried many approaches, with different and with the same thread.
I use the version 0.84.1 (0.82 was used for producing the DB file).

Your help is more than welcome. It would be great to make it work, before I will need to say sorry to some ORM libs :(

Kind Regards,
Lukasz

Kenneth Geisshirt

unread,
Nov 11, 2015, 3:49:45 AM11/11/15
to Łukasz Tokarski, realm...@googlegroups.com, rav...@gmail.com
Hey,

It is possible to share the Realm file? Doing so can help us to figure out what is wrong. You're welcome to send it to he...@realm.io.


Best,
Kenneth

--
Kenneth Geisshirt
Member of technical staff


{#HS:120147859-1854#}
Reply all
Reply to author
Forward
0 new messages