Android multidex, UnsatisfiedLinkError - could not find .so file

I am trying to add some lib (.jar and .so) to my multidex project in android studio.

when I add only a few cans to the project, everything works fine. in case I add more and more cans (other libraries) I get this error:

java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.test.digital.ocrtest-2/base.apk"],nativeLibraryDirectories=[/data/app/com.test.digital.ocrtest-2/lib/arm, /data/app/com.test.digital.ocrtest-2/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]] couldn't find "libScanovatePassportAndIDLSDK_CPP.so" 

any idea how can I tell the compiler to create a jar and so on in the same dex?

+8
android android-studio android-gradle jni
source share
2 answers

If some additional JAR files bring native libries for armeabi-v7a , and your libScanovatePassportAndIDLSDK_CPP.so is created only for armeabi , the installer will extract the wrong library set. The fix is โ€‹โ€‹not to add more copies of .so , but rather to remove other ABIs. In gradle you can use splits .

+4
source share

There is an elegant solution for this. When your APK file does not contain all the native libraries in the 64-bit version for a specific ABI, you just need to make sure that your APK file does not contain 64-bit libraries. Here is a guide to setting up your project to fix this: https://corbt.com/posts/2015/09/18/mixing-32-and-64bit-dependencies-in-android.html

Background When your application is installed on 64-bit ABI devices, the package manager scans the APK file during installation and searches for 64-bit native libraries. If he finds a suitable folder with a 64-bit library (you can check the / libs folder in your APK file if you open it with any zip client), it is assumed that all native libraries are available in 64-bit versions. If one or more native libraries is not available in the 64-bit version, the package manager will not be able to download its 32-bit version. Therefore, when an application tries to run code that relies on these native librairies, you will receive this UnsatisfiedLinkError message. This means that the 32-bit version of your library

+1
source share

All Articles