3

Fatal Exception: java.lang.UnsatisfiedLinkError dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.myapp-1/base.apk"],nativeLibraryDirectories=[/data/app/com.myapp-1/lib/arm64, /vendor/lib64, /system/lib64]]] couldn't find "libnative.so"

It only happens on the ARM64 devices. I don't setup any custom NDK build in my gradle setting.

Looks like Android Studio somehow messing up the correct folder to copy the .so file.

How does the happen and how to fix it?

shiami
  • 7,174
  • 16
  • 53
  • 68

2 Answers2

1

Maybe you're using another library that does embed .so files for arm64-v8a? Open your APK as a zip file and look inside the lib folder to see if that's the case.

Then, to fix your issue, you can use abiFilters to include only .so files for the architectures you fully support:

android {
    ....
    defaultConfig {
        ....
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }
}
ph0b
  • 14,353
  • 4
  • 43
  • 41
0

Basically what we have to do is , put your .so files inside a folder named lib (Note: it is not libs and this is not a mistake). It should be in the same structure, it should be in the APK file.

Project:

|--lib:

|--|--armeabi:

|--|--|--.so files.

1) So I've made a lib folder and inside it an armeabi folder where I've inserted all the needed .so files.

2) I then zipped the folder into a .zip (the structure inside the zip file is now lib/armeabi/*.so).

3) Then, I renamed the .zip file into armeabi.jar.

4) And, added the line compile fileTree(dir: 'libs', include: '*.jar') into dependencies {} in the gradle's build file.

  • 1
    including .so files through jars is really not recommended and can lead to many bugs. For example, abiFilters may not work. You should simply put your .so files under `jniLibs/` folders and they'll get included properly. – ph0b Aug 04 '15 at 09:53