Skip to content

Instantly share code, notes, and snippets.

@fredgrott
Created December 4, 2014 19:35
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save fredgrott/361db859908f759bc28f to your computer and use it in GitHub Desktop.
Save fredgrott/361db859908f759bc28f to your computer and use it in GitHub Desktop.
rename android app apk
// in your android.applicationVariants.all { variant ->
// or in your android.libraryVariants.all { variant ->
// code block put this:
if (variant.productFlavors[0] == null){
variant.outputs[0].outputFile = new File(variant.outputs[0].outputFile.parent,
project.ext.ourProjectName + "_"
+ variant.buildType.name + "_"
+ android.defaultConfig.versionCode + "_"
+ android.defaultConfig.versionName + ".apk")
}else{
variant.outputs[0].outputFile = new File(variant.outputs[0].outputFile.parent,
project.ext.ourProjectName + "_"
+ variant.productFlavors[0].name + "_"
+ variant.buildType.name + "_"
+ variant.mergedFlavor.versionCode + "_"
+ variant.mergedFlavor.versionName + ".apk")
}
//works for all use cases:
// app without productFlavors
// app with productFlavors and even flavorDimensions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment