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

 

posted on 2015-08-14 09:02  小老虎2  阅读(6848)  评论(4编辑  收藏  举报