12

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?

ankuranurag2
  • 2,300
  • 15
  • 30
Kristy Welsh
  • 7,828
  • 12
  • 64
  • 106

2 Answers2

0

This is documented change in android build tools 3.3.0. (gradle 4.10 and above I'm not sure) I am no gradle expert or anything like that but, I am pretty sure the code you shared above is not causing this warning. It is probably one of your dependencies that is using the API's mentioned by the warning which is now deprecated. The only workaround is to silence the warning for now if you want to continue using android build tools 3.3.0.

Similar case occurred in butterknife library too. Check those out, you might find some useful information Butterknife Issue 1431

I am personally silencing this warning and moving on. Just add the following line in gradle.properties

android.jetifier.blacklist = butterknife-compiler //replace with possible artifact name
AagitoEx
  • 484
  • 2
  • 8
0

after lots of R&D, I found the solution

what I have done is that I have removed output.zipAlign form android.applicationVariants.all file and the warning went away

Priyanka
  • 3,369
  • 1
  • 10
  • 33