文章鏈接: ?http://stackoverflow.com/questions/30474073/unsatisfiedlinkerror-nativelibrarydirectories-vendor-lib64-system-lib64
android studio 64位手機(jī)+Fresco引起的在arm64位機(jī)器上找不到對(duì)應(yīng)的so庫(kù)
我們的程序在32位機(jī)器上沒(méi)有問(wèn)題洪囤,有一天公司采購(gòu)了一臺(tái)魅族MX5
MTK的64位處理器上我們的應(yīng)用報(bào)錯(cuò)了
"nativeLibraryDirectories=[/data/app/com.lukouapp-1/lib/arm64, /vendor/lib64, /system/lib64]]] couldn't find"libxxxx.so"
仔細(xì)排查后發(fā)現(xiàn)是因?yàn)槭褂昧?a target="_blank" rel="nofollow">Fresco
通過(guò)排查fresco的issue-關(guān)于64bit的問(wèn)題發(fā)現(xiàn)
Issue#504
Issue#458
問(wèn)題原因:64位機(jī)器默認(rèn)去查找arm64-v8a目錄下是否有合適的64位庫(kù)昼捍,如果沒(méi)有則回去libs下查找32位的庫(kù)豁跑,而fresco的draw-pipeline太完善了考慮了64位的機(jī)器所以他的arm64-v8a下有so庫(kù)懦鼠,
對(duì)應(yīng)的系統(tǒng)就創(chuàng)建了lib64的文件,而不再去找32位的庫(kù)。
解決方案:
Edit your build.gradle fileasfollows:
android {//rest of your app's logicsplits {
abi {
enabletruereset()
include'x86','x86_64','arm64-v8a','armeabi-v7a','armeabi'universalApkfalse} ?}}
(*)注意上面的紅色部分要?jiǎng)h除掉最后看起來(lái)是這樣:
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.
注意:如果加入上面代碼還不行 ,可以注釋掉下面這行(如果你的主要工程目錄沒(méi)有加入lib和jar的話)
dependencies {//compile fileTree(include: ['*.jar'], dir: 'libs')}
以上方法發(fā)現(xiàn)并沒(méi)有解決形庭,采用以下的方法解決的最后
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" } } }