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 file as follows:

android {
  // rest of your app's logic
  splits {
    abi {
        enable true
        reset()
        include 'x86', 'x86_64', 'arm64-v8a', 'armeabi-v7a', 'armeabi'
        universalApk false
    }
  }
}

(*)注意上面的紅色部分要刪除掉最后看起來是這樣:
android {
  // rest of your app's logic
  splits {
    abi {
        enable true
        reset()
        include 'x86', 'x86_64', 'armeabi-v7a', 'armeabi'
        universalApk false
    }
  }
}

原理:

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 with  include, 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')
    }

 

  

        

 

 

 

參考:

http://blog.csdn.net/lihuapinghust/article/details/45825063

http://blog.csdn.net/lquanshui/article/details/19428111

http://frescolib.org/docs/multiple-apks.html#_

http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits

http://tools.android.com/tech-docs/new-build-system/tips

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM