I'm experiencing very annoying warning in my projects:
WARNING: API 'variant.getMergeResources()' is obsolete and has been replaced with 'variant.getMergeResourcesProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
REASON: It is currently called from the following trace:
...
WARNING: Debugging obsolete API calls can take time during configuration. It's recommended to not keep it on at all times.
Affected Modules: app
As this warning will become an error next year I'd like to fix it once and for all.
I've updated gradle plugin, google play services plugin and all the dependencies, but issue is still there.
Here's the project-level build.gradle
file:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'com.google.gms:google-services:4.3.0'
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And here's the module app build.gradle
file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
applicationId "com.foo.bar"
minSdkVersion 16
targetSdkVersion 28
versionCode 9
versionName "1.08"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
checkReleaseBuilds false
//If you want to continue even if errors found use following line
abortOnError false
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
...
}
apply plugin: 'com.google.gms.google-services'
As you can see, I'm not using getMergeResources()
directly, so it must be one of the dependencies. I've commented out the dependencies one by one and finally had an empty dependencies list. However, warning was still thrown. Then I figured out that commenting out apply plugin: 'com.google.gms.google-services'
fixes the issue. But I use the latest google services plugin and I obviously cannot use anything firebase related without it.
How can I fix this? I don't like downgrading gradle plugin as it's only a temporary fix.
The latest version of the Google Services Gradle Plugin (4.3.0
) is causing this, downgrading the version to 4.2.0
seems to solve the issue temporarily (source). However Google will release an updated version of this before the end of 2019. Until then;
In your project-level build.gradle
file, under buildscript -> dependencies
. Check whether you have this line
classpath 'com.google.gms:google-services:4.3.0'
if so, change it to
classpath 'com.google.gms:google-services:4.2.0'
Is a known issue, will be fixed on the next release:
Please change your classpath dependency in project level Gradle:
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
}
}
I am using it. It is working fine. This is a stable version. Hope this issue will be fixed in the future version of this dependency.
来源:https://stackoverflow.com/questions/56806004/api-variant-getmergeresources-is-obsolete-and-has-been-replaced-with-varian