Skip to content

Instantly share code, notes, and snippets.

@mbelsky
Created June 25, 2015 08:08
Show Gist options
  • Save mbelsky/3dd52ca6b074eb9bc3a7 to your computer and use it in GitHub Desktop.
Save mbelsky/3dd52ca6b074eb9bc3a7 to your computer and use it in GitHub Desktop.
Snippet for adding current version value in android apk release file name
/**
* Define 'APP_MODULE_NAME' and 'APK_NAME' vars in gradle.properties file.
*/
android {
applicationVariants.all { variant ->
variant.outputs.each { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.apk')) {
def fileName = outputFile.name.replace('.apk', "-${versionName}.apk")
fileName = fileName.replace(APP_MODULE_NAME, APK_NAME)
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