Skip to content

Instantly share code, notes, and snippets.

@fei-ke
Forked from fredgrott/renameapk
Last active August 29, 2015 14:11
Show Gist options
  • Save fei-ke/9067bf303d48f5f498b1 to your computer and use it in GitHub Desktop.
Save fei-ke/9067bf303d48f5f498b1 to your computer and use it in GitHub Desktop.
// 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