Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.