文章链接: http://stackoverflow.com/questions/30474073/unsatisfiedlinkerror-nativelibrarydirectories-vendor-lib64-system-lib64
android studio 64位手机+Fresco引起的在arm64位机器上找不到对应的so库
我们的程序在32位机器上没有问题,有一天公司采购了一台魅族MX5
MTK的64位处理器上我们的应用报错了
"nativeLibraryDirectories=[/data/app/com.lukouapp-1/lib/arm64, /vendor/lib64, /system/lib64]]] couldn't find"libxxxx.so"
仔细排查后发现是因为使用了Fresco
通过排查fresco的issue-关于64bit的问题发现
Issue#504
Issue#458
问题原因:64位机器默认去查找arm64-v8a目录下是否有合适的64位库,如果没有则回去libs下查找32位的库,而fresco的draw-pipeline太完善了考虑了64位的机器所以他的arm64-v8a下有so库,
对应的系统就创建了lib64的文件,而不再去找32位的库。
解决方案:
Edit your build.gradle fileasfollows:
android {//rest of your app's logicsplits {
abi {
enabletruereset()
include'x86','x86_64','arm64-v8a','armeabi-v7a','armeabi'universalApkfalse} }}
(*)注意上面的红色部分要删除掉最后看起来是这样:
android {//rest of your app's logicsplits {
abi {
enabletruereset()
include'x86','x86_64','armeabi-v7a','armeabi'universalApkfalse}
}
}
原理:
enable: enables the ABIs split mechanism
exclude: By default all ABIs are included, you can remove some ABIs.
include: indicate which ABIs to be included
reset(): reset the list of ABIs to be included to an empty string (this allows, in conjunctions withinclude, to indicate which one to use rather than which ones to ignore)
universalApk: indicates whether to package a universal version (with all ABIs) or not. Default is false.
注意:如果加入上面代码还不行 ,可以注释掉下面这行(如果你的主要工程目录没有加入lib和jar的话)
dependencies {//compile fileTree(include: ['*.jar'], dir: 'libs')}
以上方法发现并没有解决,采用以下的方法解决的最后
down voteIf you have only x86 and armeabi-v7a libraries, your app should automatically be installed in "32-bit mode".
Try to use this in your gradle file:
android { .... defaultConfig { .... ndk { abiFilters "armeabi-v7a", "x86" } } }