Skip to content

Instantly share code, notes, and snippets.

@dominicthomas
Created February 25, 2015 14:22
Show Gist options
  • Save dominicthomas/f78feb83a18dbfa6ffc6 to your computer and use it in GitHub Desktop.
Save dominicthomas/f78feb83a18dbfa6ffc6 to your computer and use it in GitHub Desktop.
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 19
buildToolsVersion = rootProject.ext.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
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment