realm-java icon indicating copy to clipboard operation
realm-java copied to clipboard

UnsatisfiedLinkError exception in TightDB:loadLibrary

Open tspecht opened this issue 12 years ago • 16 comments

Hi guys,

I found the following in my crash logs. Unfortunately it just says java.lang.ExceptionInInitializerError. Any ideas on this?

java.lang.ExceptionInInitializerError
       at io.realm.Realm.(Realm.java:108)
       at io.realm.Realm.createAndValidate(Realm.java:366)
       at io.realm.Realm.create(Realm.java:355)
       at io.realm.Realm.getInstance(Realm.java:314)
       at io.realm.Realm.getInstance(Realm.java:193)
       at com.my.app.common.ApplicationModule.provideRealm(ApplicationModule.java:108)
       at com.my.app.common.ApplicationModule$$ModuleAdapter$ProvideRealmProvidesAdapter.get(ApplicationModule$$ModuleAdapter.java:388)
       at com.my.app.common.ApplicationModule$$ModuleAdapter$ProvideRealmProvidesAdapter.get(ApplicationModule$$ModuleAdapter.java:352)
       at com.my.app.activities.MyActivity$$InjectAdapter.injectMembers(MyActivity$$InjectAdapter.java:86)
       at com.my.app.activities.MyActivity$$InjectAdapter.injectMembers(MyActivity$$InjectAdapter.java:23)
       at dagger.ObjectGraph$DaggerObjectGraph.inject(ObjectGraph.java:281)
       at com.my.app.MyApplication.inject(MyApplication.java:69)
       at com.my.app.common.BaseActivity.onCreate(BaseActivity.java:53)
       at com.my.app.activities.MyActivity.onCreate(MyActivity.java:153)
       at android.app.Activity.performCreate(Activity.java:5047)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2056)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2117)
       at android.app.ActivityThread.access$700(ActivityThread.java:134)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1218)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:137)
       at android.app.ActivityThread.main(ActivityThread.java:4867)
       at java.lang.reflect.Method.invokeNative(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:511)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1007)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)
       at dalvik.system.NativeStart.main(NativeStart.java)
Caused by: java.lang.UnsatisfiedLinkError: Couldn't load tightdb-jni: findLibrary returned null
       at java.lang.Runtime.loadLibrary(Runtime.java:365)
       at java.lang.System.loadLibrary(System.java:535)
       at io.realm.internal.TightDB.loadLibrary(TightDB.java:144)
       at io.realm.internal.SharedGroup.(SharedGroup.java:32)
       at io.realm.Realm.(Realm.java:108)
       at io.realm.Realm.createAndValidate(Realm.java:366)
       at io.realm.Realm.create(Realm.java:355)
       at io.realm.Realm.getInstance(Realm.java:314)
       at io.realm.Realm.getInstance(Realm.java:193)
       at com.my.app.common.ApplicationModule.provideRealm(ApplicationModule.java:108)
       at com.my.app.common.ApplicationModule$$ModuleAdapter$ProvideRealmProvidesAdapter.get(ApplicationModule$$ModuleAdapter.java:388)
       at com.my.app.common.ApplicationModule$$ModuleAdapter$ProvideRealmProvidesAdapter.get(ApplicationModule$$ModuleAdapter.java:352)
       at com.my.app.activities.MyActivity$$InjectAdapter.injectMembers(MyActivity$$InjectAdapter.java:86)
       at com.my.app.activities.MyActivity$$InjectAdapter.injectMembers(MyActivity$$InjectAdapter.java:23)
       at dagger.ObjectGraph$DaggerObjectGraph.inject(ObjectGraph.java:281)
       at com.my.app.MyApplication.inject(MyApplication.java:69)
       at com.my.app.common.BaseActivity.onCreate(BaseActivity.java:53)
       at com.my.app.activities.MyActivity.onCreate(MyActivity.java:153)
       at android.app.Activity.performCreate(Activity.java:5047)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2056)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2117)
       at android.app.ActivityThread.access$700(ActivityThread.java:134)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1218)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:137)
       at android.app.ActivityThread.main(ActivityThread.java:4867)
       at java.lang.reflect.Method.invokeNative(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:511)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1007)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)
       at dalvik.system.NativeStart.main(NativeStart.java)

tspecht avatar Nov 26 '14 17:11 tspecht

Hi @tspecht

It seems that Realm has trouble loading the c++ library. Which you can see in this line:

Couldn't load tightdb-jni: findLibrary returned null

What device are you testing on and with what version of Realm? Also are you using Android Studio or Eclipse?

cmelchior avatar Nov 27 '14 06:11 cmelchior

@cmelchior thanks for getting back. I assume the Realm version was still 0.7.3 (just shipped the update to 0.7.4 yesterday). I'm using Android Studio to develop & deploy my applications. In addition, I haven't encountered the problems on my test devices but instead got them from my crash reporting tool. They occur on a wide variety of devices (Samsung, Huawai, Sony) and are also not limited to a specific system version (occurring mostly on 4.1.2, but also on 4.4.2 and 4.2.1). Is this of any help?

tspecht avatar Nov 27 '14 10:11 tspecht

We would be very interested in knowing the exact models of those phone. Can you compile a list of the most frequent ones together with Android version. That would be incredible helpful.

cmelchior avatar Nov 27 '14 11:11 cmelchior

Sure, everything I can do ;) Unfortunately I can't get the OS version per phone :/

Samsung: -GT I8190 (63%) -Galaxy S Advance (15%) -GT I8160 (7%)

Huawai: -G525 U00 (66%) -G610 U20 (33%)

Sony: -D2403 (100%)

tspecht avatar Nov 27 '14 11:11 tspecht

Thank you very much. Now we has some concrete phones to check on. I will keep you posted.

cmelchior avatar Nov 27 '14 12:11 cmelchior

Same here. I post the full stacktrace:

java.lang.UnsatisfiedLinkError: Couldn't load tightdb-jni from loader dalvik.system.PathClassLoader[dexPath=/data/app/org.wepush.traffico2-4.apk,libraryPath=/data/app-lib/org.wepush.traffico2-4]: findLibrary returned null
       at java.lang.Runtime.loadLibrary(Runtime.java:358)
       at java.lang.System.loadLibrary(System.java:526)
       at io.realm.internal.TightDB.loadLibrary(TightDB.java:144)
       at io.realm.internal.SharedGroup.<clinit>(SharedGroup.java:32)
       at io.realm.Realm.<init>(Realm.java:108)
       at io.realm.Realm.createAndValidate(Realm.java:366)
       at io.realm.Realm.create(Realm.java:355)
       at io.realm.Realm.getInstance(Realm.java:314)
       at io.realm.Realm.getInstance(Realm.java:193)

It occurs on Samsung S4 (I9505) equipped with Android 4.4.2 (Realm version: 0.73.1). Hope it helps.

arcadefire avatar Dec 04 '14 22:12 arcadefire

I got reports about the same crashes on Samsung devices. Unfortunately I have no logcat available right now, but since it just crashes on Samsung phones it's probably the same bug. This is really causing problems here; do you already know the reason and can give us a rough date for a fixing update? Thanks in advance!

an-k avatar Dec 08 '14 15:12 an-k

Do you guys have any clue if this happens consistently on these phones? Or just sometimes?

On Mon, Dec 8, 2014 at 4:57 PM, an-k [email protected] wrote:

I got reports about the same crashes on Samsung devices. Unfortunately I have no logcat available right now, but since it just crashes on Samsung phones it's probably the same bug. This is really causing problems here; do you already know the reason and can give us a rough date for a fixing update? Thanks in advance!

— Reply to this email directly or view it on GitHub https://github.com/realm/realm-java/issues/620#issuecomment-66136286.

bmunkholm avatar Dec 08 '14 22:12 bmunkholm

I actually am not experiencing this anymore in the current version of my app!

tspecht avatar Dec 08 '14 22:12 tspecht

Which Realm version is that using?

On Mon, Dec 8, 2014 at 11:16 PM, tspecht [email protected] wrote:

I actually am not experiencing this anymore in the current version of my app!

— Reply to this email directly or view it on GitHub https://github.com/realm/realm-java/issues/620#issuecomment-66198188.

bmunkholm avatar Dec 08 '14 22:12 bmunkholm

@bmunkholm 0.74.x

tspecht avatar Dec 08 '14 22:12 tspecht

@an-k : Any details appreciated. Realm version, crashlog, specific devices? Reproducable?

bmunkholm avatar Dec 08 '14 22:12 bmunkholm

Hi @an-k and @arcadefire : We have tried to test on a lot of different devices (through a web service with many devices) without seeing the problem. tspect is not seing this anymore either. So:

  1. Do you still experience this?
  2. Is it consistently happening on the phones in question (i.e. reproduceable with the right phone), please list them
  3. Which Realm version are you using?

bmunkholm avatar Dec 10 '14 13:12 bmunkholm

Thanks a lot for your work, guys and sorry for the late response! It's constantly happening on Samsung S4 mini and Note 4 (4.4.2 / 4.4.4), versions 0.73.1 and 0.75.1. But I'm not 100% sure it's realm that causes the crash, it just suited @tspecht 's report perfectly. I managed to get remote logcats in a few hours, then it should be clear.

an-k avatar Dec 10 '14 13:12 an-k

Big sorry to you guys, the crashes did not confirm this issue.

After a lot of investigating the following turned out as the reason: My model contains List<Item> itemListGson and RealmList<Item> itemListRealm. This is a necessary workaround I found to make use of Retrofit+GSON (which fills the itemListGson). Just before storing it in realm the list is copied to itemListRealm. Kinda dirty, I know, but its just a workaround unitil realm supports JSON parsing / object initialization by default. And it did work great - so far. Anyways: On the test Samsung devices on Android 4.4.X GSON crashed - apparently because of the non-serializable class field RealmList<Item> itemListRealm.

edit: To avoid this, just configure the used Gson by building it via Gson gson = GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();

So this issue was not confirmed here. Thanks a lot for your work and even more for your brilliant support!

an-k avatar Dec 11 '14 16:12 an-k

Ok - thanks for the feedback - glad we can help! We will close this one for now then.

bmunkholm avatar Dec 11 '14 16:12 bmunkholm