1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
apply plugin: 'com.android.application'
import com.android.build.OutputFile;
dependencies {
compile project(':lib')
}
// map for the version code for ABIs.
// x86 is more important because x86 devices also support arm.
// Same for mips
ext.versionCodes = ["armeabi-v7a":1, "mips":2, "x86":3, "all":0]
android {
compileSdkVersion rootProject.latestCompileSdk
buildToolsVersion = rootProject.buildToolsVersion
// This actual the app version code. Giving ourselves 100,000 values [0, 99999]
defaultConfig.versionCode = 123
productFlavors {
gingerbread {
minSdkVersion 10
versionCode = 1
}
icecreamSandwich {
minSdkVersion 14
versionCode = 2
}
}
splits {
abi {
enable = true
universalApk = true
exclude "x86_64", "mips64", "arm64-v8a", "armeabi"
}
}
// make per-variant version code
applicationVariants.all { variant ->
// get the version code for the flavor
def apiVersion = variant.productFlavors.get(0).versionCode
// assign a composite version code for each output, based on the flavor above
// and the density component.
variant.outputs.each { output ->
// get the key for the abi component
def key = output.getFilter(OutputFile.ABI) == null ? "all" : output.getFilter(OutputFile.ABI)
// set the versionCode on the output.
output.versionCodeOverride = apiVersion * 1000000 + project.ext.versionCodes.get(key) * 100000 + defaultConfig.versionCode
}
}
}
|