问题
I am building release apk based on the ABI because of apk size to publish on Play store.
So I started apk building for ABI = armeabi-v7a then building ABI = x86 and ABI = areambi
so my gradle look like this
app gradle
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.package"
minSdkVersion 18
targetSdkVersion 26
versionCode 1
versionName "1.0"
multiDexEnabled true
ndk {
abiFilters "armeabi-v7a"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
externalNativeBuild {
ndkBuild {
path 'src/main/jni/Android.mk'
}
}
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.
// Resets the list of ABIs that Gradle should create APKs for to none.
reset()
// Specifies a list of ABIs that Gradle should create APKs for.
include "armeabi-v7a"
// Specifies that we do not want to also generate a universal APK that includes all ABIs.
universalApk false
}
}
}
So my question
- I need to make changes in
versionCode 1
for each ABI, so which version code for which ABI should I use.
回答1:
I have to make 2 different build
Build 1: for armeabi-v7a
versionCode 21614001
splits {
abi {
enable true
reset()
include "armeabi-v7a"
universalApk false
}
}
Build 2 : for x86
versionCode 61614001
splits {
abi {
enable true
reset()
include "x86"
universalApk false
}
}
Added native library accordingly to the abi supported.
After that published the apk Build 1 and Build 2 together will show you the supported devices.
回答2:
productFlavors{
arm{
ndk{
abiFilters "arm64-v8a" , "armeabi" , "armeabi-v7a"
}
}
x86{
ndk{
abiFilters "x86" , "x86_64"
}
}
}
来源:https://stackoverflow.com/questions/47302063/generating-multiple-apk-according-to-the-native-abi