React-native-webrtc: Shared object loading issue on Android x64

Created on 25 Aug 2016  路  4Comments  路  Source: react-native-webrtc/react-native-webrtc

I'm came across issues with react-native failing to load .so files on Android x64 when react-native-webrtc is added to a fresh project.

When the application starts up, it's looking for an x64 version of libgnustl_shared.so which I think is purposefully omitted by the default /app/build.gradle in a fresh react project:

    defaultConfig {
        ...
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }

I experimented with tweaks to build.gradle and gradle.properties, but couldn't get the app to live through loading all .so files.

After reverting and starting from scratch, I upgraded gradle to 2.14 and the build started failing.
gradle began complaining that libjingle_peerconnection_so.so was missing from the arm64 directory somewhere in /node_modules/react-native-webrtc/build/......


Starting from a fresh project:

> react-native init Demo
> cd Demo/
> react-native run-android

> npm install react-native-webrtc --save
> react-native link
-  rnpm-install info Linking react-native-webrtc android dependency
-  rnpm-install info Android module react-native-webrtc has been successfully linked 
-  rnpm-install info Linking react-native-webrtc ios dependency 
-  rnpm-install info iOS module react-native-webrtc has been successfully linked 
> react-native run-android

It launches and dies immediately:

Shutting down VM
FATAL EXCEPTION: main
Process: com.demo, PID: 7013
java.lang.UnsatisfiedLinkError: dlopen failed: "/data/data/com.demo/lib-main/libgnustl_shared.so" is 32-bit instead of 64-bit
    at java.lang.Runtime.load(Runtime.java:332)
    at java.lang.System.load(System.java:1069)
    at com.facebook.soloader.DirectorySoSource.loadLibraryFrom(DirectorySoSource.java:71)
    at com.facebook.soloader.DirectorySoSource.loadLibrary(DirectorySoSource.java:42)
    at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:299)
    at com.facebook.soloader.DirectorySoSource.loadLibraryFrom(DirectorySoSource.java:65)
    at com.facebook.soloader.DirectorySoSource.loadLibrary(DirectorySoSource.java:42)
    at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:299)
    at com.facebook.soloader.DirectorySoSource.loadLibraryFrom(DirectorySoSource.java:65)
    at com.facebook.soloader.DirectorySoSource.loadLibrary(DirectorySoSource.java:42)
    at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:299)
    at com.facebook.soloader.DirectorySoSource.loadLibraryFrom(DirectorySoSource.java:65)
    at com.facebook.soloader.DirectorySoSource.loadLibrary(DirectorySoSource.java:42)
    at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:299)
    at com.facebook.soloader.DirectorySoSource.loadLibraryFrom(DirectorySoSource.java:65)
    at com.facebook.soloader.DirectorySoSource.loadLibrary(DirectorySoSource.java:42)
    at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:299)
    at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:247)
    at com.facebook.react.bridge.ReactBridge.staticInit(ReactBridge.java:24)
    at com.facebook.react.bridge.ReactBridge.<clinit>(ReactBridge.java:20)
    at com.facebook.react.bridge.ReactBridge.staticInit(ReactBridge.java:24)
    at com.facebook.react.bridge.NativeMap.<clinit>(NativeMap.java:22)
    at com.facebook.react.JSCConfig$1.getConfigMap(JSCConfig.java:14)
    at com.facebook.react.XReactInstanceManagerImpl.onJSBundleLoadedFromServer(XReactInstanceManagerImpl.java:704)
    at com.facebook.react.XReactInstanceManagerImpl.recreateReactContextInBackgroundInner(XReactInstanceManagerImpl.java:384)
    at com.facebook.react.XReactInstanceManagerImpl.createReactContextInBackground(XReactInstanceManagerImpl.java:355)
    at com.facebook.react.ReactRootView.startReactApplication(ReactRootView.java:216)
    at com.facebook.react.ReactActivity.onCreate(ReactActivity.java:107)
    at android.app.Activity.performCreate(Activity.java:6272)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2387)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2494)
    at android.app.ActivityThread.access$900(ActivityThread.java:157)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1356)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5551)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
  Force finishing activity com.demo/.MainActivity

Most helpful comment

You may want to look at https://github.com/jitsi/jitsi-meet-react/commit/30a9ca40750f6a01a5eae0f8fa5c428ce541b147 where I've fixed the above for the jitsi/jitsi-meet-react project.

All 4 comments

You may want to look at https://github.com/jitsi/jitsi-meet-react/commit/30a9ca40750f6a01a5eae0f8fa5c428ce541b147 where I've fixed the above for the jitsi/jitsi-meet-react project.

Taking a look now! I appreciate the direct commit link!

That's exactly what I was looking for. I didn't realize the ndk abiFilters didn't automatically exclude the unassociated .sos. This was my first time using gradle and you probably just saved me hours more of experimenting with it.

I can't thank you enough!!

:+1:

Was this page helpful?
0 / 5 - 0 ratings