1

I'm writing an app and as a DB I've use Realm. Everything was fine, until the app was published. Now I've faced with this error on some devices:

java.lang.ExceptionInInitializerError
       at io.realm.Realm.<init>(Realm.java:199)
       at io.realm.Realm.createAndValidate(Realm.java:585)
       at io.realm.Realm.create(Realm.java:554)
       at io.realm.Realm.getInstance(Realm.java:527)
       at com.magisto.utils.RealmUtils.createRealmInstance(RealmUtils.java:22)
       at com.magisto.infrastructure.viewcount.repository.RealmViewStorage.<init>(RealmViewStorage.java:26)
       at com.magisto.infrastructure.module.ViewStorageModule.provideViewStorage(ViewStorageModule.java:19)
       at com.magisto.infrastructure.module.ViewStorageModule_ProvideViewStorageFactory.get(ViewStorageModule_ProvideViewStorageFactory.java:23)
       at com.magisto.infrastructure.module.ViewStorageModule_ProvideViewStorageFactory.get(ViewStorageModule_ProvideViewStorageFactory.java:9)
       at com.magisto.service.background.ViewCountingService.onHandleIntent(ViewCountingService.java:70)
       at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:137)
       at android.os.HandlerThread.run(HandlerThread.java:60)
Caused by: java.lang.UnsatisfiedLinkError: Couldn't load realm-jni: findLibrary returned null
       at java.lang.Runtime.loadLibrary(Runtime.java:365)
       at java.lang.System.loadLibrary(System.java:535)
       at io.realm.internal.RealmCore.loadLibrary(RealmCore.java:144)
       at io.realm.internal.SharedGroup.<clinit>(SharedGroup.java:35)
       at io.realm.Realm.<init>(Realm.java:199)
       at io.realm.Realm.createAndValidate(Realm.java:585)
       at io.realm.Realm.create(Realm.java:554)
       at io.realm.Realm.getInstance(Realm.java:527)
       at com.magisto.utils.RealmUtils.createRealmInstance(RealmUtils.java:22)
       at com.magisto.infrastructure.viewcount.repository.RealmViewStorage.<init>(RealmViewStorage.java:26)
       at com.magisto.infrastructure.module.ViewStorageModule.provideViewStorage(ViewStorageModule.java:19)
       at com.magisto.infrastructure.module.ViewStorageModule_ProvideViewStorageFactory.get(ViewStorageModule_ProvideViewStorageFactory.java:23)
       at com.magisto.infrastructure.module.ViewStorageModule_ProvideViewStorageFactory.get(ViewStorageModule_ProvideViewStorageFactory.java:9)
       at com.magisto.service.background.ViewCountingService.onHandleIntent(ViewCountingService.java:70)
       at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:137)
       at android.os.HandlerThread.run(HandlerThread.java:60)

I've used Realm version 0.82.0 from jcenter. The issue is was found on Samsung S4 mini, Samsung S5, Samsung Tab 3 7.0, and several other devices. How can I fix it?

Grimmy
  • 2,041
  • 1
  • 17
  • 26
  • Can you see the Android version from crash logs? We fixed a problem which could cause this problem before 4.3 https://github.com/realm/realm-java/pull/1364 . But I see Samsung S5 is also there which should be AOSP 4.4. – beeender Aug 12 '15 at 04:36
  • @beeender sure. 34% has 4.4.2, 22% has 4.1.1, 18% has 4.2.2 – Grimmy Aug 12 '15 at 06:15
  • Did the problem happen after a store update? http://stackoverflow.com/questions/18111739/why-do-some-android-phones-cause-our-app-to-throw-an-java-lang-unsatisfiedlinker here is a general loadLibrary problem seems to be caused by play store's delta update. And after it happened, it will happen always? Or it gets recovered when the next time user open the app? – beeender Aug 12 '15 at 06:20
  • @beeender, it could be store update, I'm not sure. It is about 5 crashes per 1 user, so looks like it did not recover. – Grimmy Aug 12 '15 at 06:38
  • Have you ever met this problem on your first version? I hate to say this, but if it is a store's problem, it would be difficult to fix it from Realm side... – beeender Aug 12 '15 at 06:46
  • First version of the app didn't have Realm, so there was no problem. We actually have many .so libraries, but problem occurs only with Realm :( – Grimmy Aug 12 '15 at 06:50
  • Do you have any newly added `.so` after the first version than Realm's? When do you load other `.so`? Before the first time accessing Realm or after? – beeender Aug 12 '15 at 06:55
  • Looks like before first Realm accessing. We load it in static{...} block of some static class – Grimmy Aug 12 '15 at 07:06
  • Is it possible to add some logic in your app to check if Realm's `.so` does exist and get some logs back? – beeender Aug 12 '15 at 07:16
  • @beeender, yes, I can add – Grimmy Aug 12 '15 at 07:22
  • Also, if you can, maybe use our snapshot which has https://github.com/realm/realm-java/pull/1364 . As mentioned before, it solved a similar problem for device versions lower than 4.3 . Thanks a lot for you help! – beeender Aug 12 '15 at 07:25

0 Answers0