不同渠道设置不同的versionName
productFlavors {
oppo {
versionName "1.1.1"
}
vivo {
versionName "1.1.2"
}
}
applicationVariants.all { variant ->
variant.outputs.all { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.apk')) {
if (variant.buildType.name == 'debug') {
// variant.getPackageApplication().outputDirectory = new File("debug")
//获取versionName 重命名apk variant.productFlavors[0].propertie 里面有很多属性 可以打印查看自己需要的属性
def versionName = variant.productFlavors[0].properties.get("versionName") ? variant.productFlavors[0].properties.get("versionName") : defaultConfig.versionName
def fileName = "${versionName}-debug.apk"
outputFileName = fileName
}
}
}
}