API 'variant.getMergeResources()' is obsolete and has been replaced with 'variant.getMergeResourcesProvider()'

Makalele :

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.

Roshana Pitigala :

Two versions of the Google Services Gradle Plugin (4.3.0 & 4.3.1) are causing this, upgrading the version to 4.3.2 seems to solve the issue;


In your project-level build.gradle file, under buildscript -> dependencies, check whether you have this line

classpath 'com.google.gms:google-services:4.3.x'

if so, change it to

classpath 'com.google.gms:google-services:4.3.3'

Edit: Click here to check the newest version. (4.3.3) at time of Edit.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=120574&siteId=1