Created
February 25, 2015 14:28
-
-
Save dominicthomas/6676e81b2d6d1a30ea8f to your computer and use it in GitHub Desktop.
Example of density apk split in gradle: https://android.googlesource.com/platform/tools/base/+/2101d189d85dd46f865726b9b7aa0012832a6d9c/build-system/tests/regular/densitySplit/build.gradle
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
import com.android.build.OutputFile; | |
ext { | |
buildToolsVersion = System.env.CUSTOM_BUILDTOOLS != null ? System.env.CUSTOM_BUILDTOOLS : '20.0.0' | |
} | |
buildscript { | |
def gradleVersion = System.env.CUSTOM_GRADLE != null ? System.env.CUSTOM_GRADLE : '0.14.0' | |
repositories { | |
if (System.env.CUSTOM_REPO != null) { | |
maven { url System.env.CUSTOM_REPO } | |
} else { | |
mavenCentral() | |
} | |
} | |
dependencies { | |
classpath "com.android.tools.build:gradle:$gradleVersion" | |
} | |
} | |
apply plugin: 'com.android.application' | |
android { | |
compileSdkVersion 19 | |
buildToolsVersion = rootProject.ext.buildToolsVersion | |
defaultConfig { | |
versionCode 12 | |
minSdkVersion 16 | |
targetSdkVersion 20 | |
buildConfigField "String", "FOO", "\"bar\"" | |
} | |
splits { | |
density { | |
enable true | |
exclude "ldpi", "tvdpi", "xxxhdpi", "400dpi", "560dpi" | |
compatibleScreens 'small', 'normal', 'large', 'xlarge' | |
} | |
} | |
} | |
// map for the version code | |
ext.versionCodes = [all:1, mdpi:2, hdpi:3, xhdpi:4, xxhdpi:5] | |
android.applicationVariants.all { variant -> | |
// assign different version code for each output | |
variant.outputs.each { output -> | |
def key = output.getFilter(OutputFile.DENSITY) == null ? "all" : output.getFilter(OutputFile.DENSITY) | |
output.versionCodeOverride = project.ext.versionCodes.get(key) * 100 + android.defaultConfig.versionCode | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment