Studio多渠道打包並生成自定義apk檔名字
阿新 • • 發佈:2019-01-09
android {
// replace the umeng channel value according to flavor channel property.
applicationVariants.all{ variant ->
// change output apk path.
variant.outputs.each { output ->
if ("${variant.getBuildType().name}" == "release") {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyMMdd-HHmmss")
def dateFlag = "${dateFormat.format(new Date())}"
def versionFlag = "${android.defaultConfig.versionName}"
def flavorFlag = "${variant.productFlavors.get(0).name}"
def newName = "releases/qspLauncher_" + dateFlag + "_v" + versionFlag + "_" + flavorFlag + ".apk"
if (output.zipAlign) {
output.zipAlign.outputFile = new File(getBuildDir(), newName)
}
}
}
}
}