Search code examples
androidc++boostandroid-ndk

Cannot find boost shared library files in Android application


For Intellij (and Android Studio) I built a JNI shared library that links to boost libraries that I'd link to include in my Android app. I called System.loadLibrary on my .so file but it fails to find boost libraries when I run it. I get the following error:

java.lang.UnsatisfiedLinkError: dlopen failed: library "libboost_unit_test_framework-clang-mt-x32-1_77.so.1.77.0" not found: needed by /data/app/~~28p8gv9ihFbZAejYd9c9yw==/sensoft.applications.dt1demo-0IEJ8o6cHOk0kputNbnbNQ==/base.apk!/lib/x86/libssi_utils_java.so in namespace classloader-namespace

Even though the boost .so files are there in the libs/x86 directory (I built them in x86 with the android toolchain to run on my emulator) but it did manage to find the .so file that I built in the same directory.

I placed my .so file and all the required boost .so files in the libs/x86 directory and included the following as a jni source in my build.gradle file:

sourceSets {
        main.jniLibs.srcDirs = ['libs']
    }

But my application can't seem to find the boost shared libraries specifically.


Solution

  • Android's install process will not extract libraries that don't have the suffix .so. You have to remove the version suffix of the library (which serves no purpose on Android anyway, because libraries are not all installed to a single common path).