Skip to content

Instantly share code, notes, and snippets.

@mark-software
Last active March 13, 2022 02:44
Show Gist options
  • Save mark-software/e95875ad6533143cd33439fd57f08b88 to your computer and use it in GitHub Desktop.
Save mark-software/e95875ad6533143cd33439fd57f08b88 to your computer and use it in GitHub Desktop.
Example showing how to name APK files with the version and build number. This goes in the `android.buildTypes` block.
buildTypes {
applicationVariants.all { variant ->
def version = "${variant.versionName}-${variant.versionCode}"
variant.outputs.all { output ->
if (variant.buildType.name == "debug") {
outputFileName = "AppName-debug-${version}.apk"
} else if (variant.buildType.name == "staging") {
outputFileName = "AppName-staging-${version}.apk"
} else if (variant.buildType.name == "release") {
outputFileName = "AppName-production-${version}.apk"
}
}
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment