文章鏈接: ?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" } } }