buildGralde下
android {
.....
applicationVariants.all { variant ->
//这个修改输出的APK路径
if (variant.buildType.name != "debug") {//防止AS无法安装debug包(apk)
variant.getPackageApplication().outputDirectory = new File(project.rootDir.absolutePath + "/apk")
}
variant.getPackageApplication().outputScope.apkDatas.forEach { apkData ->
//这个修改输出APK的文件名
apkData.outputFileName = "mine_" +
new Date().format("yyyy-MM-dd", TimeZone.getTimeZone("UTC")) + "_" +
variant.buildType.name + "_" +
variant.versionName + "_" +
variant.flavorName +
".apk"
}
}
}
网友评论