【发布时间】:2020-11-17 13:45:17
【问题描述】:
我有一个 libfoo.so 库,我将它用于架构 armeabi 用于我的旧 Android 系统。今天我正在构建新架构arm64-v8a,我已经在gradle abiFilters += 'arm64-v8a' 中正确配置,并且我解压缩了我的apk,我可以在myApp.apk/lib/arm64-v8a 中找到我的libfoo.so 库。我没有这个libfoo.so 库的源代码,所以我使用了前一个为armeabi 构建的源代码。但我得到如下错误:
2020-11-17 20:56:23.039 13083-13556/? W/System.err: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/sg.com.aa.bb-1/base.apk"],nativeLibraryDirectories=[/data/app/sg.com.aa.bb-1/lib/arm64, /data/app/sg.com.aa.bb-1/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]] couldn't find "libfoo.so"
你可以看到这条路径/data/app/sg.com.aa.bb-1/base.apk!/lib/arm64-v8a,我很确定我的libfoo.so文件在里面,但是为什么它一直说couldn't find libfoo.so?
我对文件libfoo.so运行file命令,它显示:
ELF 32-bit LSB pie executable ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /system/, stripped
之前有人问过类似的问题,arm64-v8a 应该兼容那些 32 位库,比如this。还有this,上面写着64-bit devices also support their 32-bit variants. Using arm64-v8a devices as an example, the device can also run armeabi and armeabi-v7a code. Note, however, that your application will perform much better on 64-bit devices if it targets arm64-v8a rather than relying on the device running the armeabi-v7a version of your application.
在这种情况下,是否有其他可能导致上述UnsatisfiedLinkError?
结论:
我终于明白了@Jake 的意思,我对所谓的“arm64-v8a 也支持 32 位”有点困惑。是的,它确实支持,但前提是它以 64 位模式运行,并且一旦 Android 应用程序以 64 位模式启动,它就无法执行任何 32 位 C 库。所以我必须想办法强制应用程序在 32 位模式下运行。
【问题讨论】: