android{
....
applicationVariants.all { variant ->
variant.outputs.each { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.apk')) {
File outputDirectory = new File(outputFile.parent);
def fileName
if (variant.buildType.name == "release") {
fileName = "app_name_v${defaultConfig.versionName}_${variant.productFlavors[0].name}.apk"
} else {
fileName = "app_name_v${defaultConfig.versionName}_beta.apk"
}
output.outputFile = new File(outputDirectory, fileName)
}
}
}
....
}
AS3.0需要用这个
applicationVariants.all { variant ->
variant.outputs.all {
def fileName = "great${defaultConfig.versionName}.apk"
outputFileName = fileName
}
}