-
-
Save bhardwajAbhi/6713f778096533c1582621bcbc672daf to your computer and use it in GitHub Desktop.
An example showing an apk split by architecture and screen density.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| apply plugin: 'com.android.application' | |
| android { | |
| compileSdkVersion 23 | |
| buildToolsVersion "23.0.2" | |
| defaultConfig { | |
| applicationId "application.yourcompany.domain" | |
| versionCode 100 | |
| versionName "1.0.0" | |
| minSdkVersion 15 | |
| targetSdkVersion 23 | |
| // Limit included translations to english and 1 other (german) | |
| resConfigs "en", "de" | |
| } | |
| buildTypes { | |
| debug { | |
| debuggable true | |
| } | |
| release { | |
| debuggable false | |
| minifyEnabled true | |
| shrinkResources true | |
| zipAlignEnabled true | |
| proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | |
| } | |
| } | |
| splits { | |
| abi { | |
| enable true | |
| universalApk true | |
| exclude "arm64-v8a", "mips", "mips64" | |
| } | |
| density { | |
| enable true | |
| exclude "ldpi", "tvdpi", "400dpi", "560dpi" | |
| compatibleScreens 'small', 'normal', 'large', 'xlarge' | |
| } | |
| } | |
| applicationVariants.all { variant -> | |
| // assign different version code for each output | |
| variant.outputs.each { output -> | |
| def abi = output.getFilter(com.android.build.OutputFile.ABI); | |
| def density = output.getFilter(com.android.build.OutputFile.DENSITY); | |
| def apiCode = android.defaultConfig.minSdkVersion.getApiLevel() ; | |
| def abiCode = project.versionCodesAbi.get(abi, 0); | |
| def densityCode = project.versionCodesDensity.get(density, 0); | |
| output.versionCodeOverride = (apiCode * 100000 | |
| + densityCode * 10000 | |
| + abiCode * 1000 | |
| + android.defaultConfig.versionCode | |
| ); | |
| println(":app:buildVersionCodes apiCode: " + apiCode | |
| + ", densityCode: " + densityCode | |
| + ", abiCode: " + abiCode | |
| + ", output: " + output.versionCodeOverride | |
| ); | |
| } | |
| } | |
| } | |
| dependencies { | |
| compile fileTree(include: ['*.jar'], dir: 'libs') | |
| testCompile 'junit:junit:4.12' | |
| // Your dependencies here | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Top-level build file where you can add configuration options common to all sub-projects/modules. | |
| ext { | |
| versionCodesAbi = ['armeabi':1, 'armeabi-v7a':2, 'arm64-v8a':3, 'mips':4, 'x86':5, 'x86_64':6]; | |
| versionCodesDensity = [all:0, mdpi:1, hdpi:2, xhdpi:3, xxhdpi:4, xxxhdpi:5]; | |
| } | |
| buildscript { | |
| repositories { | |
| jcenter() | |
| } | |
| dependencies { | |
| classpath 'com.android.tools.build:gradle:1.5.0' | |
| // NOTE: Do not place your application dependencies here; they belong | |
| // in the individual module build.gradle files | |
| } | |
| } | |
| allprojects { | |
| repositories { | |
| jcenter() | |
| } | |
| } | |
| task clean(type: Delete) { | |
| delete rootProject.buildDir | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment