简体   繁体   中英

UnsatisfiedLinkError on Android 5.0 Lollipop

I am loading my native library by:

try {
       System.loadLibrary("myNative");
} catch (UnsatisfiedLinkError e) {
       //java.lang.UnsatisfiedLinkError here
       System.load("/data/data/com.my.app/my_native/libmyNative.so");
}

The above code works fine on other devices except Android 5.0 Lollipop. When run on Android 5.0 Lollipop device, I constantly get the following error:

java.lang.UnsatisfiedLinkError: dlopen failed: "/data/data/com.my.app/my_native/libmyNative.so" is 32-bit instead of 64-bit
at java.lang.Runtime.load(Runtime.java:331)
at java.lang.System.load(System.java:982)

How to solve this problem?

=== UPDATE ====

I copied the native library from lib/<archType>/libmyNative.so to /data/data/com.my.app/my_native/libmyNative.so and then use the above code to load the library.

It seems that some part of the way of packaging your libs (copying them from lib/<archType>/libmyNative.so to /data/data/com.my.app/my_native/libmyNative.so ) confuses the installer. When installing an APK, it should already automatically extract the libraries of the right arch type and have them available to System.loadLibrary - you shouldn't need to copy anything manually into a custom directory like my_native .

Is <archType> in this case one of the existing ( armeabi , armeabi-v7a , etc) or something of your own? If it isn't one of the standard ones, the installer won't know that your app contains 32 bit native code, and thus will launch your app's process in the preferred mode (64 bit).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM