Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UnsatisfiedLinkError nativeLibraryDirectories=[/vendor/lib64, /system/lib64

The situation is as follows:

I have a 64 bit apk which should a 32bit shared object(.so file) from /system/lib. But the apk crashes when running and reports:

UnsatisfiedLinkError nativeLibraryDirectories=[/vendor/lib64, /system/lib64

I think it tries to search my .so file which is located in /system/lib from /system/lib64, then error happens.

How could I make it search from /system/lib instead of /system/lib64?

like image 884
user2326258 Avatar asked Mar 15 '23 22:03

user2326258


2 Answers

This is happening because you are bundling at least one 64-bit native library. Android detects this and decides to seek out the rest of the .so files in 64-bit only locations. It doesn't find them because you are only building for 32-bit architectures.

To verify that this is your problem, open up the built apk and look in the "lib" dir. Each subdirectory therein represents a native binary architecture. If you are not building all of the native .so files for that architecture, the directory shouldn't be there. Find out why it is and stop it.

One example of this is Crashlytics which can quietly bundle itself. The resulting crash only appears on 64-bit devices because 32-bit devices never search 64-bit architecture directories.

You have to prune the architectures you are not fully supporting from all your third party middleware.

like image 75
Michael Labbé Avatar answered Mar 18 '23 12:03

Michael Labbé


If you have only x86 and armeabi-v7a libraries, your app should automatically be installed in "32-bit mode".

Try to use this in your gradle file:

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

like image 21
Farhad Avatar answered Mar 18 '23 12:03

Farhad