安卓打包命名
2020-03-02 本文已影响0人
MasterPaul
打包的时候希望apk文件名是日期+版本号,修改app中的gradle文件即可
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// https://developer.android.com/studio/build/configure-apk-splits.html
def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
if(variant.buildType.name.equals('release')){
def date = new Date().format("yyyyMMdd" , TimeZone.getTimeZone("GMT+08"))
output.outputFileName = "release_${date}_${versionName}.apk"
}
}
}