Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnsatisfiedLinkError when trying to load RealmReactModule #1187

Closed
DeArchiTech opened this issue Aug 4, 2017 · 32 comments
Closed

UnsatisfiedLinkError when trying to load RealmReactModule #1187

DeArchiTech opened this issue Aug 4, 2017 · 32 comments

Comments

@DeArchiTech
Copy link

DeArchiTech commented Aug 4, 2017

Hello There

We have an Android app that uses both the Android Realm SDK and the React Native Realm SDK.

Our app is in production and there are around 10 crashes ( <0.1% of users) that is related to java.lang.UnsatisfiedLinkError

Stacktrace

`Caused by java.lang.UnsatisfiedLinkError

java.lang.Runtime.load (Runtime.java:332)
java.lang.System.load (System.java:1069)
com.facebook.soloader.DirectorySoSource.loadLibraryFrom (DirectorySoSource.java:71)
com.facebook.soloader.DirectorySoSource.loadLibrary (DirectorySoSource.java:42)
com.facebook.soloader.SoLoader.loadLibraryBySoName (SoLoader.java:299)
com.facebook.soloader.SoLoader.loadLibrary (SoLoader.java:247)
io.realm.react.RealmReactModule. (RealmReactModule.java)
io.realm.react.RealmReactPackage.createNativeModules (RealmReactPackage.java:15)

com.facebook.react.NativeModuleRegistryBuilder.processPackage (NativeModuleRegistryBuilder.java:107)
 com.facebook.react.ReactInstanceManager.processPackage (ReactInstanceManager.java:1021)
com.facebook.react.ReactInstanceManager.createReactContext (ReactInstanceManager.java:959)
com.facebook.react.ReactInstanceManager.access$600 (ReactInstanceManager.java:108)
com.facebook.react.ReactInstanceManager$ReactContextInitAsyncTask.doInBackground (ReactInstanceManager.java:225)

com.facebook.react.ReactInstanceManager$ReactContextInitAsyncTask.doInBackground (ReactInstanceManager.java:203)
android.os.AsyncTask$2.call (AsyncTask.java:295)
java.util.concurrent.FutureTask.run (FutureTask.java:237)
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1113)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:588)
java.lang.Thread.run (Thread.java:818)`

Android Realm Plugin : 'io.realm:realm-gradle-plugin:3.3.2'
React Realm Dependencies : "realm": "^1.8.3"

it seems like Facebook's DirectorySoSource.java file is trying to load in the RealmModule, but an UnsatisfiedLinkError has occurred. What are some possible reasons of why such an error would be thrown??

@DeArchiTech
Copy link
Author

Details of exception message:

Caused by java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "" referenced by "/data/app/com.aadhk.woinvoice-1/lib/arm/librealmreact.so"...

@kneth
Copy link
Contributor

kneth commented Aug 8, 2017

@noobieHacker Do you only see the crashes on 64 bit devices? If so, excluding 64 bit (and thereby force loading 32 bit .so files) might be a workaround.

@kneth
Copy link
Contributor

kneth commented Aug 21, 2017

@noobieHacker Did you solve the issue by excluding 64 bit?

@kneth
Copy link
Contributor

kneth commented Aug 28, 2017

@noobieHacker I am closing the issue. If the issue wan't solved by excluding 64 bit, please reopen the issue.

@kneth kneth closed this as completed Aug 28, 2017
@parohy
Copy link

parohy commented Oct 4, 2017

I am getting same stacktrace, bu with java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "_ZN5realm4util11uuid_stringEv" /lib/x86/librealmreact.so at the end.
I added abiFilters 'x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'arm64-v8a'

.

@kneth
Copy link
Contributor

kneth commented Oct 5, 2017

@tomas-paronai I suggest that you remove x86_64 and arm64-v8a since RN only supports 32 bit architectures.

@abury
Copy link

abury commented Jun 30, 2018

@kneth how do you go about doing that? We're getting this issue but we're only including "armeabi-v7a", "x86" in our abiFilters

@abury
Copy link

abury commented Jun 30, 2018

This seems to only be occuring in 2.11.0. Downgrading to 2.2.8 resolved the issue

@behiunforgiven
Copy link

I have the same issue on 2.11.0

@kneth
Copy link
Contributor

kneth commented Jul 3, 2018

@abury @behiunforgiven Which symbol cannot be located?

@abury
Copy link

abury commented Jul 4, 2018

@kneth The same one as @tomas-paronai listed:
java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "_ZN5realm4util11uuid_stringEv" /lib/x86/librealmreact.so

👍

@kneth
Copy link
Contributor

kneth commented Jul 4, 2018

@abury Can you try to upgrade to 2.12.0?

We are currently using https://github.com/facebook/SoLoader to load the .so file but maybe we should switch to https://github.com/KeepSafe/ReLinker. At Realm, we have good experiences with ReLinker (used by Realm Java).

The path (/lib/x86) does look a bit odd. I mean, how can an app install a .so file in a system folder?

@tje3d
Copy link

tje3d commented Jul 15, 2018

@kneth crashes on 2.12.0 and 2.13.0.

java.lang.UnsatisfiedLinkError: couldn't find DSO to load: librealmreact.so

Edit: as @abury said, downgrading to 2.2.8 resolved the issue.

@kneth
Copy link
Contributor

kneth commented Aug 13, 2018

I am not able to reproduce it on my little test app (using Realm JS 2.14.2 and RN 0.55.4) running on my OnePlus One (32 bit ARM device).

@abury @tje3d Can you provide an simple app which reproduces the issue?

@abury
Copy link

abury commented Aug 15, 2018

@kneth I haven't experienced the issue with the latest version of RN and Realm, so it's all good on my end.

@kneth
Copy link
Contributor

kneth commented Aug 15, 2018

@abury Happy to hear that.

@tje3d Can you try to upgrade?

@tje3d
Copy link

tje3d commented Aug 15, 2018

@kneth thanks, i'l upgrade tomorrow

@tje3d
Copy link

tje3d commented Aug 16, 2018

Still same

realm: 2.14.2
react-native: 0.56.0

More info:

com.android.tools.build: gradle:2.3.3
buildToolsVersion = 27.0.3
minSdkVersion = 16
compileSdkVersion = 27
targetSdkVersion = 27
supportLibVersion = 26.1.0
enableProguardInReleaseBuilds = true
08-16 15:55:50.271 17794 17813 E SoLoader: Could not load: librealmreact.so
--------- beginning of crash
08-16 15:55:50.272 17794 17813 E AndroidRuntime: FATAL EXCEPTION: Thread-2
08-16 15:55:50.272 17794 17813 E AndroidRuntime: Process: com.test, PID: 17794
08-16 15:55:50.272 17794 17813 E AndroidRuntime: java.lang.UnsatisfiedLinkError: couldn't find DSO to load: librealmreact.so
08-16 15:55:50.272 17794 17813 E AndroidRuntime: 	at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:522)
08-16 15:55:50.272 17794 17813 E AndroidRuntime: 	at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:420)
08-16 15:55:50.272 17794 17813 E AndroidRuntime: 	at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:370)
08-16 15:55:50.272 17794 17813 E AndroidRuntime: 	at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:335)
08-16 15:55:50.272 17794 17813 E AndroidRuntime: 	at io.realm.react.RealmReactModule.<clinit>(RealmReactModule.java:59)
08-16 15:55:50.272 17794 17813 E AndroidRuntime: 	at io.realm.react.RealmReactPackage.createNativeModules(RealmReactPackage.java:31)
08-16 15:55:50.272 17794 17813 E AndroidRuntime: 	at com.facebook.react.NativeModuleRegistryBuilder.processPackage(NativeModuleRegistryBuilder.java:109)
08-16 15:55:50.272 17794 17813 E AndroidRuntime: 	at com.facebook.react.ReactInstanceManager.processPackage(ReactInstanceManager.java:1175)
08-16 15:55:50.272 17794 17813 E AndroidRuntime: 	at com.facebook.react.ReactInstanceManager.processPackages(ReactInstanceManager.java:1145)
08-16 15:55:50.272 17794 17813 E AndroidRuntime: 	at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:1086)
08-16 15:55:50.272 17794 17813 E AndroidRuntime: 	at com.facebook.react.ReactInstanceManager.access$900(ReactInstanceManager.java:116)
08-16 15:55:50.272 17794 17813 E AndroidRuntime: 	at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:916)
08-16 15:55:50.272 17794 17813 E AndroidRuntime: 	at java.lang.Thread.run(Thread.java:764)
08-16 15:55:50.273  1476  6456 W ActivityManager:   Force finishing activity com.test/.MainActivity
08-16 15:55:50.274  1476  6456 D ActivityTrigger: ActivityTrigger activityPauseTrigger 

@kneth
Copy link
Contributor

kneth commented Aug 16, 2018

@tje3d I notice enableProguardInReleaseBuilds = true and think of #1960. Could you try to unzip your apk file and see what .so files it contains?

@ariefwidiatmoko
Copy link

I solve the issue with, using the latest realm 2.22.0
enableProguardInReleaseBuilds = false

@martnst
Copy link

martnst commented Feb 14, 2019

The same crash occurred to my app after rebuilding it from scratch with React Native 0.58. Comparing the android/app/build.gradle with my old repo, I noticed that the abiFilters was not present anymore. Thanks @tomas-paronai for you comment.

I was able to reproduce it.

Steps to reproduce this:

  • $ react-native init RNTestApp
  • $ cd RNTestApp
  • $ yarn add realm
  • $ react-native link
  • run via Android Studio

Crash Log

E/SoLoader: Error when loading lib: dlopen failed: "/data/data/com.rntestapp/lib-main/librealmreact.so" is 32-bit instead of 64-bit lib hash:  47698cc5a6c9aa1799fbd19efe73cb1 search path is /data/app/com.rntestapp-8JMLgQo3CER0yhlhw8s-Ww==/lib/arm64
    couldn't find DSO to load: librealmreact.so caused by: dlopen failed: "/data/data/com.rntestapp/lib-main/librealmreact.so" is 32-bit instead of 64-bit
E/AndroidRuntime: FATAL EXCEPTION: create_react_context
    Process: com.rntestapp, PID: 13166
    java.lang.UnsatisfiedLinkError: couldn't find DSO to load: librealmreact.so caused by: dlopen failed: "/data/data/com.rntestapp/lib-main/librealmreact.so" is 32-bit instead of 64-bit
        at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:738)
        at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:591)
        at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:529)
        at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:484)
        at io.realm.react.RealmReactModule.<clinit>(RealmReactModule.java:56)
        at io.realm.react.RealmReactPackage.createNativeModules(RealmReactPackage.java:31)
        at com.facebook.react.ReactPackageHelper.getNativeModuleIterator(ReactPackageHelper.java:42)
        at com.facebook.react.NativeModuleRegistryBuilder.processPackage(NativeModuleRegistryBuilder.java:40)
        at com.facebook.react.ReactInstanceManager.processPackage(ReactInstanceManager.java:1212)
        at com.facebook.react.ReactInstanceManager.processPackages(ReactInstanceManager.java:1182)
        at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:1120)
        at com.facebook.react.ReactInstanceManager.access$900(ReactInstanceManager.java:123)
        at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:943)
        at java.lang.Thread.run(Thread.java:780)

@kneth
Copy link
Contributor

kneth commented Feb 18, 2019

@martnst Yes, the explanation is dlopen failed: "/data/data/com.rntestapp/lib-main/librealmreact.so" is 32-bit instead of 64-bit lib and the fix is using abiFilters. For 64 bit support, see #2221.

@MichaelHuy
Copy link

Still got the error on latest version React Native (0.59.1), Realm 2.25.0. A crash app on some Android devices.

@kneth
Copy link
Contributor

kneth commented Mar 21, 2019

@MichaelHuy Do you by any chance mix 32 bit and 64 bit? Realm is currently only 32 bit.

@MichaelHuy
Copy link

@kneth Thanks for your feedback. How can I mix 32 bit and 64 bit? I remembered I removing all 64 configurations ("arm64-v8a", "x86_64") but still got the error?

@kneth
Copy link
Contributor

kneth commented Mar 21, 2019

@MichaelHuy I am asking since you are using RN 0.59 which supports 64 bit. Please post the stack trace if possible.

@MichaelHuy
Copy link

@kneth java.lang.UnsatisfiedLinkError: couldn't find DSO to load: librealmreact.so caused by: dlopen failed: "/data/data/com.nox.identiv/lib-main/librealmreact.so" is 32-bit instead of 64-bit at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:738) at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:591) at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:529) at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:484) at io.realm.react.RealmReactModule.<clinit>(RealmReactModule.java:56) at io.realm.react.RealmReactPackage.createNativeModules(RealmReactPackage.java:31) at com.facebook.react.ReactPackageHelper.getNativeModuleIterator(ReactPackageHelper.java:42) at com.facebook.react.NativeModuleRegistryBuilder.processPackage(NativeModuleRegistryBuilder.java:40) at com.facebook.react.ReactInstanceManager.processPackage(ReactInstanceManager.java:1212) at com.facebook.react.ReactInstanceManager.processPackages(ReactInstanceManager.java:1182) at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:1120) at com.facebook.react.ReactInstanceManager.access$900(ReactInstanceManager.java:123) at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:943) at java.lang.Thread.run(Thread.java:818)

@kneth
Copy link
Contributor

kneth commented Mar 21, 2019

@MichaelHuy Your issue is similar to facebook/SoLoader#29 - but that's not helping you.

I suggest that you unzip the apk file and examine all the .so files. If just one is 64 bit, it can explain why you see the error.

@AlexandreRozier
Copy link

AlexandreRozier commented Mar 26, 2019

For those who wonder, I had the same issue (RN 0.58.6, Realm 2.25.0) and solved it with

defaultConfig{
        ndk {
            // Tells Gradle to build outputs for the following ABIs and package
            // them into your APK.
            abiFilters 'x86', 'armeabi-v7a'//, 'x86_64', 'armeabi'
        }
}

And also:

  • def versionCodes = ["armeabi-v7a": 1, "x86": 2/*, "arm64-v8a": 3*/]
  • include "armeabi-v7a", "x86"//, "arm64-v8a" // uncommented coz realm does not support 64 bit yet

Edit: use this only if you're not planning on releasing a 64 bits version of your app

@kneth
Copy link
Contributor

kneth commented Mar 27, 2019

@AlexandreRozier Many places 🤔. Thanks for the update.

@brayanL
Copy link

brayanL commented Apr 11, 2019

@AlexandreRozier your solution that implies that side effects could exist?

@kneth
Copy link
Contributor

kneth commented Apr 12, 2019

@brayanL The solution above requires that all your libraries come in 32 bit versions. And that you only use the 32 bit versions (even if a 64 bit version exists).

@bmunkholm bmunkholm added the faq label May 7, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests