splits{
// Configures multiple APKs based on ABI.
abi{
// Enables building multiple APKs per ABI.
enable true
// By default all ABIs are included, so use reset() and include to specify that we only
// want APKs for x86, armeabi-v7a, and mips.
reset()
// Specifies a list of ABIs that Gradle should create APKs for.
// 32位cpu:armeabi-v7a、x86,64位cpu:arm64-v8a,、x86_64
include "armeabi-v7a", "arm64-v8a"
// exclude 'armeabi'
// Specifies that we want to also generate a universal APK that includes all ABIs.
universalApk true
}
}
- enable: 是否启用ABI拆分机制
- reset():重置ABI列表为只空字符串,一半和include、exclude一起使用,如果要用必须在include和exclude前面
- include:指明要包含哪些ABI,目前使用最多的伪64位处理器的arm64-v8a,其次才是armeabi-v7a
- exclude:默认包含下所有ABI,可以移除一些ABI
- universalApk:是否打包一个通用版本,包含所有的ABI,默认值为 false
此时打包会输出三个包
关于abiFilters
ndk {
abiFilters 'arm64-v8a',"armeabi-v7a"
}
注意:如果配置abiFilters universalApk 要为true
此时输出到包同为:
第三个包app-doctor-universal-debug.apk里面会包含arm64-v8a和armeabi-v7a文件夹中的so文件
- abiFilters过滤就是在splits的基础之上,再选择打入universal中所包含的几种处理器架构的文件夹的