同步警告:
WARNING: API’variantOutput.getPackageApplication()’isobsolete and has been replaced with’variant.getPackageApplicationProvider()’.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.To determine whatiscalling variantOutput.getPackageApplication(), use -Pandroid.debug.obsoleteApi=true on the command line to display a stack trace.
Affected Modules: app
修改方法:
android {
….
//自定义apk名称含版本号信息
android.applicationVariants.all { variant ->
// 更新至Android Studio 3.3 gradle 4.10.1
variant.outputs.all {
outputFileName = “Nanosic_OTA_${variant.versionCode}-${variant.versionName}-${releaseTime()}.apk”
}
//更新前
/*
variant.outputs.all { output ->
def fileName = “Nanosic_OTA_${defaultConfig.versionCode}-${defaultConfig.versionName}-${releaseTime()}.apk”
//def fileName = outputFile.name.replace(“app”, “${rootProject.ext.appName}-${releaseTime()}-${defaultConfig.versionCode}-${defaultConfig.versionName}”)
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith(‘.apk’)) {
//这里修改apk文件名
outputFileName = fileName
}
}
*/
}
}
//获取编译时间
static def releaseTime() {
return new Date().format(“yyyy-MM-dd”, TimeZone.getTimeZone(“UTC”))
}
原文:https://www.cnblogs.com/blogs-of-lxl/p/10306145.html