React-native: React native expection java.lang.UnsatisfiedLinkError: dlopen failed: “/data/data/{package}/lib-main/libgnustl_shared.so” is 32-bit instead of 64-bit

Created on 19 Nov 2016  ·  16Comments  ·  Source: facebook/react-native

I am trying to integrate React Native with my existing Android App. I am getting the following exception when initializing React Native Screen:

java.lang.UnsatisfiedLinkError: dlopen failed: "/data/data/com.snapdeal.main/lib-main/libgnustl_shared.so" is 32-bit instead of 64-bit
The App is only crashing on 64-bit devices.

As per my learning so far, I've found this issue reported on React Native Repo, but the solution suggested in this thread is not helpful as I am not using any external SO library in existing App.

Apart from above, I've realized another difference in library structure on the device where my App is installed. I am comparing structure of my App vs react native demo app.

React demo App

root@generic_x86_64:/data/data/com.react.demo/lib # ls
libfb.so
libfolly_json.so
libglog.so
libglog_init.so
libgnustl_shared.so
libicu_common.so
libimagepipeline.so
libjsc.so
libreactnativejni.so
libreactnativejnifb.so

root@generic_x86_64:/data/data/com.react.demo/lib-main # ls
dso_deps
dso_lock
dso_manifest
dso_state

My App

root@generic_x86_64:/data/data/com.my.app/lib-main # ls
dso_deps
dso_lock
dso_manifest
dso_state
libfb.so
libfolly_json.so
libglog.so
libglog_init.so
libgnustl_shared.so
libicu_common.so
libimagepipeline.so
libjsc.so
libreactnativejni.so
libreactnativejnifb.so

Sharing few more details about my project:

package.json

{
"name": "projectname",
"version": "1.0.0",
"description": "Native NPM",
"main": "index.js",
"scripts": {
"test": "echo "Error: no test specified" && exit 1",
"start": "node node_modules/react-native/local-cli/cli.js start"
},
"repository": {
"type": "git",
"url": ""
},
"author": "Ishan D",
"license": "ISC",
"dependencies": {
"react": "^15.3.2",
"react-native": "^0.37.0",
"react-native-linear-gradient": "^1.5.15",
"rn-viewpager": "^1.1.3"
},
"devDependencies": {}
}

dependencies used in android native project

ext {
compileSdkVersion = 24
buildToolsVersion = '24.0.2'
minSdkVersion = 16
targetSdkVersion = 24
supportLibrariesVersion = '23.0.1'
playServiceVersion = '9.0.2'

dep = [
        fabricPlugin          : 'io.fabric',
        fabricMavenUrl        : 'https://maven.fabric.io/public',
        fabricClasspath       : 'io.fabric.tools:gradle:1.+',

        playServiceClasspath  : 'com.google.gms:google-services:1.3.0-beta1',
        playServicePlugin     : 'com.google.gms.google-services',

        playServiceAppindexing: "com.google.android.gms:play-services-appindexing:$playServiceVersion",
        playServiceLocation   : "com.google.android.gms:play-services-location:$playServiceVersion",
        playServiceVision     : "com.google.android.gms:play-services-vision:$playServiceVersion",
        playServiceAuth       : "com.google.android.gms:play-services-auth:$playServiceVersion",
        playServiceBase       : "com.google.android.gms:play-services-base:$playServiceVersion",
        playServiceIdentity   : "com.google.android.gms:play-services-identity:$playServiceVersion",
        playServiceAnalytics  : "com.google.android.gms:play-services-analytics:$playServiceVersion",
        playServiceGcm        : "com.google.android.gms:play-services-gcm:$playServiceVersion",

        underCouchClasspath   : 'de.undercouch:gradle-download-task:2.0.0',
        underCouchPluigin     : 'de.undercouch.download',

        crashlytics           : 'com.crashlytics.sdk.android:crashlytics:2.4.0@aar',

        moengage              : 'com.moengage:moe-android-sdk:6.0.29',

        supportV4             : "com.android.support:support-v4:$supportLibrariesVersion",
        supportAppCompatV7    : "com.android.support:appcompat-v7:$supportLibrariesVersion",
        supportCardviewV7     : "com.android.support:cardview-v7:$supportLibrariesVersion",
        supportDesignV7       : "com.android.support:design:$supportLibrariesVersion",

        okhttp                : 'com.squareup.okhttp:okhttp:2.5.0',
        junit                 : 'junit:junit:4.12',
        mockito               : 'org.mockito:mockito-core:1.10.19'
]

}

Any clue is appreciated.

  • React Native version: 0.37.
  • Platform: Android
  • Operating System: Android M +
Locked

Most helpful comment

Thanks @sduqlsc that worked for me too. Though I only needed to add:

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

Btw, the above code is also part of the boilerplate Android project that is created when you would run react-native init. Though I'm not sure what the impact would be of disabling arm64 / x86_64 output.

All 16 comments

If you just run something trivial like the demo app can you get that working on the 64-bit device you are testing with?

@lacker Yes, demo app was working and I got my App working as well. The problem was because of react-native android dependencies. I've used the same maven url as in docs here without looking at my projects dir structure.

@ishan-dhingra @lacker I'm having this same issue... My maven url is correct though...

React Native 0.41.2, integrating into an existing app. Error occurs only when trying to render a react view. Overlay permissions are set correctly, and the React packager is running.

When I run app (using 'react-native run-android' command) at 64-bit smartphone it worked fine, but release version apk crashed instantly, while same apk also working fine at 32-bit smartphone

RcaHandler: Build: Sony/E5603/E5603:6.0/30.2.A.0.100/167960284:user/release-keys
RcaHandler: java.lang.UnsatisfiedLinkError: dlopen failed: "/data/data/com.fooapp/lib-main/libgnustl_shared.so" is 32-bit instead of 64-bit
RcaHandler: at java.lang.Runtime.load(Runtime.java:332)
RcaHandler: at java.lang.System.load(System.java:1069)

do you solve you problem ? so did i have this problem

+1

Running RN 0.43.3. Worked fine on my Nexus 6, doesn't work on my Pixel. Both are on Android 7.1.2.

I can run the app if I add this to my build.gradle file, but then other things seem to break in my React views.

packagingOptions {
    exclude '/lib/mips64/**'
    exclude '/lib/arm64-v8a/**'
    exclude '/lib/x86_64/**'
}

+1, same error on API 23 device when using 0.44.2 with existing app integration.
After adding following seems working:

  1. locating the gradle.properties file in the root project, and add Android.useDeprecatedNdk=true.

  2. in the build.gradle of the app:

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

        packagingOptions {  
            exclude "lib/arm64-v8a/librealm-jni.so"  
        }  
    }  
}  

In this way, using 32bit so instead of 64 bit, still, hope there's an official solution.

Thanks @sduqlsc that worked for me too. Though I only needed to add:

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

Btw, the above code is also part of the boilerplate Android project that is created when you would run react-native init. Though I'm not sure what the impact would be of disabling arm64 / x86_64 output.

@mattijsf glad to hear that. 👍

@sduqlsc @mattijsf 👍🏻 thanks man. I tried to put ndk id defaultConfig and finally it works on my Xiaomi Redmi Note 4. Android Marshmallow.

No official words from the react team?

It's also in effect when using Litho lib

Thanks @sduqlsc @mattijsf
Iam using fresco and unity.
and placing

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

inside defaultConfig solved my problem

But i want to know impact of this configuration , Thanks

@BALUSANGEM the reason why should config certain ndk abiFilters is that this is configured in the mk file—— check out your react native project directory\node_modules\react-native\ReactAndroid\src\main\jni\Application.mk

image

As for the impact, some 3rd party libraries may only provide armeabi instead of "armeabi-v7a", "x86". So in my opinion, there is a risk of app crash.

I have the same problem,I must add 'armeabi', 'arm64-v8a' to ndk,
ndk {
abiFilters "armeabi-v7a", "x86", 'armeabi', 'arm64-v8a'
}

How to solve it?

I used

exclude '/lib/mips64/**'
exclude '/lib/arm64-v8a/**'
exclude '/lib/x86_64/**'

and it doesn't work but If I use those:

        exclude 'lib/armeabi-v7a/libgnustl_shared.so'
        exclude 'lib/x86/libgnustl_shared.so'

I'm able to build application and run. But I get explicitly error:

 java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[........] couldn't find "libgnustl_shared.so"
 at java.lang.Runtime.loadLibrary0(Runtime.java:984)
 at java.lang.System.loadLibrary(System.java:1530)

[Edit]

That helps me:
https://stackoverflow.com/questions/40694285/react-native-expection-java-lang-unsatisfiedlinkerror-dlopen-failed-data-dat

Was this page helpful?
0 / 5 - 0 ratings

Related issues

janmonschke picture janmonschke  ·  3Comments

DreySkee picture DreySkee  ·  3Comments

grabbou picture grabbou  ·  3Comments

aniss picture aniss  ·  3Comments

axelg12 picture axelg12  ·  3Comments