In android app, is it possible to use arm library for a aarch64 cpu?
I found an android app in github, it was written by c++ and use the jni. in its jniLibs i only found the "armeabi-v7a" directory, and all the jni files(.so) were Stored here. my android phone cpu architecture is aarch64(arm-v8a), and the app can run fine on my phone. but after i move the SDK in my own app, it always prompts the error
java.lang.UnsatisfiedLinkError: Native library (com/sun/jna/android-aarch64/libjnidispatch.so) not found in resource path (.)
but at the example app when i remove the same '.so' file it says:
java.lang.UnsatisfiedLinkError: Native library (com/sun/jna/android-arm/libjnidispatch.so) not found in resource path (.)
so, what happen？
Typically, an Android device does support multiple ABI's, and 64 bit devices do support native code build for certain 32 bit architectures.
For instance, arm64(64 bit) devices will always also support armeabi-v7a (32bit), to ensure compatibility with older apps. This is a requirement directly from Google.
For instace, to see which architectures your device supports, run:
adb shell getprop ro.product.cpu.abi
- Lolipop & higher:
adb shell getprop ro.product.cpu.abilist
You should see a list of several ABI's as the result of the command.
I have read recently a devblog from Realm in which they tackled some JNI-related issues. One of them was similar to what you're facing.
Their conclusion was that Android gets confused when the same app needs to load 64bit & 32bit native libraries, and only tries to load the 64 bit versions, even if a dependency only has the 32bit version of its native code.
In your case, you try to load a native library build for 32bits, but Android tries to load its 64 bit version. This could happen if one of your other dependencies has 64bit native libraries.
The devblog I mentioned: https://academy.realm.io/posts/kenneth-geisshirt-tales-developing-sdks-at-scale/
Search for "More .so Issues"
Hope this helps