Tuesday, 22 January 2019

I've just upgraded gradle and I am getting a warning about an obsolete call. How to fix?

I am using gradle plugin version 3.3.0 and my gradle wrapper is using distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip

I am using the following code in my app/build.gradle file:

applicationVariants.all { variant ->
    variant.outputs.each { output ->
        def apk = output.outputFile //happens here (line 26)
        def newName

        if (variant.buildType.name == "release") {
            newName = "ediary.apk"
        } else {
            newName = "ediary-debug.apk"
        }

        output.outputFileName = new File(
                "./build/",
                output.outputFile.name)

        if (output.zipAlign) {
            output.outputFileName = new File(
                    "./build/",
                    newName.replace("-unaligned", ""))
        }
    }
}

The project builds, but I am getting this warning:

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. REASON: Called from: C:\Users\my name\StudioProjects\core\app\build.gradle:26

How do I rewrite this to avoid the warning?



from I've just upgraded gradle and I am getting a warning about an obsolete call. How to fix?

No comments:

Post a Comment