1

After upgrading 'Android Gradle plugin' to 3.4.0, I have got a warning message in /app/build.gradle

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 more information.

I have tried 'android.debug.obsoleteApi=true' in 'gradle.properties' as recommended, then I got this message.

REASON: Called from: [android project path]/app/build.gradle:31

The code containing line 31 is the code below.

android { buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' signingConfig signingConfigs.release applicationVariants.all { variant -> variant.outputs.each { output -> project.ext { appName = 'my_app' } def newName = output.outputFile.name newName = newName.replace("app-", "$project.ext.appName-") newName = newName.replace("-release", "-" + defaultConfig.versionName) def relativeRootDir = output.packageApplication.outputDirectory.toPath().relativize(rootDir.toPath()).toFile() output.outputFileName = new File("$relativeRootDir/", newName) } } } } } 

The line 31 is

def newName = output.outputFile.name 

Is this part using API 'variantOutput.getPackageApplication()'? What should I do to solve this warning?

2
  • Are you using fabric? Commented May 3, 2019 at 8:18
  • No, I am not using. Commented May 3, 2019 at 16:19

1 Answer 1

1

After I have changed 'app/build.gradle' not to use line 31, the warning message disappears.

 applicationVariants.all { variant -> variant.outputs.all { project.ext { appName = 'my_app' } def newName = outputFileName newName = newName.replace("app-", "$project.ext.appName-") newName = newName.replace("-release", "-" + defaultConfig.versionName) outputFileName = "${variant.name}" + newName } } 
Sign up to request clarification or add additional context in comments.

1 Comment

Still getting that warning on gradle plugin 5.4.1.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.