首页 > 文章 > Android : Android Studio 更新至gradle 4.10.1后Variants API变化

Android : Android Studio 更新至gradle 4.10.1后Variants API变化

同步警告:

WARNING: API variantOutput.getPackageApplication() is obsolete 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 what is calling 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_OdTA_${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")) }

 

时间:2019-01-22 21:26:21阅读(835)
联系我们 - 留言反馈
© 2017 版权所有 鲁ICP备17052893号