Skip to content

Instantly share code, notes, and snippets.

@christianascone
Created June 16, 2017 07:25
Show Gist options
  • Save christianascone/5e4c48de77b358aa965825faf2f3c8eb to your computer and use it in GitHub Desktop.
Save christianascone/5e4c48de77b358aa965825faf2f3c8eb to your computer and use it in GitHub Desktop.
Gradle instruction for renaming apk with app version
applicationVariants.all { variant ->
variant.outputs.each { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.apk')) {
def version = defaultConfig.versionName
//version = version.replaceAll('\\.', '_')
def fileName = "appName_v" + version + ".apk"
if(variant.name.equals("variantName")){
fileName = "appName_variant_v" + version + ".apk"
}
output.outputFile = new File(outputFile.parent, fileName)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment