这是用于更改输出应用程序文件名(.apk)的代码。可以通过为分配一个不同的值来配置名称newName
android { applicationVariants.all{ variant -> def newName = "ApkName"; variant.outputs.each { output -> def apk = output.outputFile; newName += "-v" + defaultConfig.versionName; if (variant.buildType.name == "release") { newName += "-release.apk"; } else { newName += ".apk"; } if (!output.zipAlign) { newName = newName.replace(".apk", "-unaligned.apk"); } output.outputFile= new File(apk.parentFile, newName); logger.info("INFO: Set outputFile to " +output.outputFile + " for [" +output.name+ "]"); } } }