首页  编辑  

如何从APK当中排除不需要ABI,例如去掉x86_64减少APK体积?

Tags: /Android/   Date Created:

Exclude abi from apk

In my application I use renderscript which has native code for x86, armeabi-v7a and mips (~2.7Mb each). Also I read that the mips architecture has just a few devices. So I'd like to bundle my application in two APKs: universal (eg. x86 and armeabi-v7a) and mips. I found that split section helps to create apk for mips, but universal apk still contains mips architecture. So my question is how to exclude abi from result apk?
https://stackoverflow.com/questions/32334063/exclude-abi-from-apk

如果你的APK,只在某个平台,比如ARM下运行,那么可以考虑打包的时候,不要打包其他平台的SO文件,以便减少APK文件的体积。例如如果你启用了RenderScript,那么就会自动打包好多个平台的so文件进去,结果体积暴增。
简单的方法:
修改app build.gradle,增加下面内容即可:
android 
{
  defaultConfig {
    ndk {
    abiFilters "armeabi-v7a", "armeabi"
}   } }