I use a native library in my application that is only compiled for armeabi, armeabi-v7a and x86.
When this library is loaded on a 64-bit device like the Samsung S6, the application crashes with an UnsatisfiedLinkError
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.myapp-2/base.apk"],nativeLibraryDirectories=[/data/app/com.myapp-2/lib/arm64, /vendor/lib64, /system/lib64]]] couldn't find "libfoo.so" at java.lang.Runtime.loadLibrary(Runtime.java:366) at java.lang.System.loadLibrary(System.java:989)
The library is closed source unfortunately. Is there any way to fix this without recompiling the library with 64-bit targets?
On 64-bit Windows, a 64-bit process cannot load a 32-bit dynamic-link library (DLL). Additionally, a 32-bit process cannot load a 64-bit DLL.
APK is ZIP. You can open it and check directory lib to see which architectures are supported. If there is no directory lib , it supports all architectures. 64-bit Android is backwards compatible and can run 32-bit applications.
arm64-v8a. This ABI is for ARMv8-A based CPUs, which support the 64-bit AArch64 architecture. It includes the Advanced SIMD (Neon) architecture extensions. You can use Neon intrinsics in C and C++ code to take advantage of the Advanced SIMD extension.
When you install an APK on Android, the system will look for native libraries directories (armeabi, armeabi-v7a, arm64-v8a, x86, x86_64, mips64, mips) inside the lib
folder of the APK, in the order determined by Build.SUPPORTED_ABIS
.
If your app happen to have an arm64-v8a
directory with missing libs, the missing libs will not be installed from another directory, the libs aren't mixed. That means you have to provide the full set of your libraries for each architecture.
So, to solve your issue, you can remove your 64-bit libs from your build, or set abiFilters to package only 32-bit architectures:
android { .... defaultConfig { .... ndk { abiFilters "armeabi", "armeabi-v7a", "x86", "mips" } } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With