Android Studio APK输出文件配置

1
2
3
4
5
6
7
8
9
10
11
android{
applicationVariants.all { variant ->
variant.outputs.each { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.apk')) {
def dirName = APP_OUTPUT_DIR + "v${defaultConfig.versionName}"
def fileName = outputFile.name.replace(".apk", "-${defaultConfig.versionName}.apk")
output.outputFile = new File(dirName, fileName)
}
}
}

APP_OUTPUT_DIRgradle.properties,如:

1
2
#小盘beta版 输出路径
APP_OUTPUT_DIR = F\:\\100bei\\xiaopan\\dev\\