Skip to content

Instantly share code, notes, and snippets.

@OSemenovBoyarka
Last active January 30, 2017 15:48
Show Gist options
  • Save OSemenovBoyarka/dc3e63fd6776469aff13 to your computer and use it in GitHub Desktop.
Save OSemenovBoyarka/dc3e63fd6776469aff13 to your computer and use it in GitHub Desktop.
build.gradle extension to rename all output apks to <name>-<version>-<version_code> template
android {
applicationVariants.all { variant ->
variant.outputs.each { output ->
def filename = output.outputFile.name.replace(".apk", "-" + variant.versionName+"-"+variant.versionCode + ".apk")
//we should replace this only for release builds, because it cause bugs in development
if (filename.contains("release")){
output.outputFile = new File(getProject().getRootDir(),
"${getProject().getName()}${File.separator}apk${File.separator}${filename}")
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment