Search code examples
androidarmjava-native-interface

How to use "armeabi" .so-files on other architectures?


I create a legacy app for Android 6 and higher. I need to include some .so-files that are build for the "armeabi"-architecture. I don't have the source code for these shared objects so I can't build these for other architectures.

The architectures of the target devices are "armeabi-v7a" and "arm64-v8a". Both devices can run native binaries for "armeabi", I have tested this with adb (How to find ARM processor version on android device?).

The .so-files are in "/app/src/main/jniLibs/armeabi/****.so", but I get a "JNI : Unsatisfied Link Error" during runtime, so it is not using them.

How can I force the device to use these files, although they are not optimized for the runtime, but the only files I can access.

Thank you for any help.

I use Android Studio 2021, Gradle 7, minSdkVersion 21, targetSdkVersion 31, compileSdkVersion 31


Solution

  • Finally I solved the problem! After days of desperation, I got it working by downgrading Gradle from 7.1.2 to 3.2.0.

    The old Gradle version logs:

    Unable to strip library '.....\app\build\intermediates\transforms\mergeJniLibs\debug\0\lib\armeabi\lib.so' due to missing strip tool for ABI 'ARMEABI'. Packaging it as is.

    And then all devices, also 64-bit-devices, pick the "armeabi"-libraries.

    By setting android.defaultConfig.ndk { abiFilters 'armeabi' } in app\build.gradle, it also works with Gradle 7.