Skip to content Skip to sidebar Skip to footer

Android Studio: Unsatisfiedlinkerror: Findlibrary Returned Null - Loading Native Library

I am making an app in Android Studio which uses two libraries. A native library with an Android wrapper and a jar-library. For some reason, the native library won't load if the oth

Solution 1:

I found the problem. The other jar I wanted to add uses internally a C++ library with support for armeabi, armeabi-v7a, x86 and mips. The native library I was using all this time supported only armeabi.

The device I am using for testing is a armeabi-v7a device. All this time when I was using the native library, the device checked for the library in the armeabi-v7a of my libs directory. If it couldn't find it there, it would try the armeabi directory.

When I load the other jar with support for 4 different architectures, the device loads the armeabi-v7a library. As it found an armeabi-v7a library for the jar, it will try to load the native library for the same architecture. If the library wasn't found, it will not check the armeabi directory as a backup, so the findLibrary returns null, hence the UnsatisfiedLinkError.

I solved it by making a directory for the armeabi architecture and copying the .so-library of the armeabi-v7a directory into it.

Solution 2:

defaultConfig {
    ...

    ndk {
        abiFilters "armeabi-v7a", "x86", "armeabi", "mips"
    }

}

Post a Comment for "Android Studio: Unsatisfiedlinkerror: Findlibrary Returned Null - Loading Native Library"