Android studio: UnsatisfiedLinkError: findLibrary returned null - loading native library

前端 未结 2 1129
遥遥无期
遥遥无期 2021-01-11 16:13

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

相关标签:
2条回答
  • 2021-01-11 16:41

    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.

    0 讨论(0)
  • 2021-01-11 16:48
    defaultConfig {
        ...
    
        ndk {
            abiFilters "armeabi-v7a", "x86", "armeabi", "mips"
        }
    
    }
    
    0 讨论(0)
提交回复
热议问题