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 } } }