3

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

Jan Knoblauch
  • 219
  • 1
  • 3
  • 20
  • First you should check that the .so files actually are included in the APK. It's possible that the build tools simply are ignoring them since armeabi support was deprecated long ago. If your app includes any .so files built for armeabi-v7a or arm64-v8a then you may have to remove those; otherwise Android might get confused about which .so files to use. – Michael Mar 17 '22 at 10:20
  • Thank you very much for your answer. The extracted APK includes the .so files in the armeabi directory. It is the only directory in the lib folder. If I rename the directory to "ameabi-v7a", it works on the older device. But if I rename it to "arm64-v8a" the other device thinks the libs are 64-Bit, but they are 32-Bit. My problem is, that the devices do not look for the "armeabi" directory. – Jan Knoblauch Mar 17 '22 at 10:45

2 Answers2

2

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.

Jan Knoblauch
  • 219
  • 1
  • 3
  • 20
  • I have a similar problem. This allows armeabi jniLibs, but it doesn't seem to allow a mix of armeabi and armeabi-v7a libs. I have added 'armeabi-v7a' to android.defaultConfig.ndk.abiFilters list and the original problem returns – ReubenBeeler Jul 20 '22 at 20:12
  • Sorry, I don't know how to mix different library types - if possible. – Jan Knoblauch Jul 21 '22 at 00:04
  • all good. I was worried that dropping armeabi libs in armeabi-v7a folder would cause problems, but it is fine. The armeabi libs simply don't take advantage of FLOP hardware in newer CPUs (that should use armeabi-v7a libs), so it's just a little slower than it could be. – ReubenBeeler Jul 21 '22 at 18:30
0

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.

Alex Cohn
  • 56,089
  • 9
  • 113
  • 307