API 'variantOutput.getPackageApplication()' is obsolete and has been replaced with 'variant.getPa...

同步警告:

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

    原文作者:徐小星
    原文地址: https://www.jianshu.com/p/1b26dd2f3a8b
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞