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

Viewed 401

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

2 Answers

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.

You should be able to rename the /app/src/main/jniLibs/armeabi directory to armeabi-v7a and have the APK run on both 32-bit and 64-bit devices, if you don't have other native libraries (a.k.a. shared objects) in your app. But remember that you cannot publish such app on Play Store: Google requires 64-bit build from all apps now.

Related