在app的build.gradle文件下编辑如下:
buildTypes {
android.applicationVariants.all { variant ->
def _debug = ""
if (variant.buildType.name != 'release') {
_debug = "_debug"
}
variant.outputs.all { output ->
def buildDateTime = new Date().format("yyyyMMddHH", TimeZone.getTimeZone("GMT+08:00"))
def fileName = "软件名称_v${variant.versionName}(${buildDateTime})${_debug}.apk"
outputFileName = new File("../output", fileName)
}
}
}
简化代码:
buildTypes {
android.applicationVariants.all { variant ->
variant.outputs.all { output ->
def buildDateTime = new Date().format("yyyyMMddHH",TimeZone.getTimeZone("GMT+08:00"))
def fileName = "软件名_v${variant.versionName}.apk"
outputFileName = new File("", fileName)
}
}
}
*不填写输出路径会导出到默认输出路径
sync一下即可生成到指定位置指定文件名