API'variant.getMergeResources()'已过时,并已替换为'variant.getMergeResourcesProvider()' [英] API 'variant.getMergeResources()' is obsolete and has been replaced with 'variant.getMergeResourcesProvider()'

查看:744
本文介绍了API'variant.getMergeResources()'已过时,并已替换为'variant.getMergeResourcesProvider()'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在项目中遇到非常烦人的警告:

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.

我已经更新了gradle插件,google play服务插件和所有依赖项,但是问题仍然存在.

I've updated gradle plugin, google play services plugin and all the dependencies, but issue is still there.

这是项目级别的build.gradle文件:

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
}

这是模块应用程序build.gradle文件:

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'

如您所见,我没有直接使用getMergeResources(),因此它必须是依赖项之一.我已经逐一注释掉了依赖项,最后有了一个空的依赖项列表.但是,仍然引发警告.然后我发现注释apply plugin: 'com.google.gms.google-services'可以解决此问题.但是我使用的是最新的Google Services插件,如果没有它,我显然不能使用任何与Firebase相关的东西.

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.

我该如何解决?我不喜欢将gradle插件降级,因为它只是一个临时解决方案.

How can I fix this? I don't like downgrading gradle plugin as it's only a temporary fix.

推荐答案

两个版本的

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;

在项目级build.gradle文件中的buildscript -> dependencies下,检查是否有此行

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'

修改:点击此处以查看最新版本. (4.3.3)进行编辑.

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

这篇关于API'variant.getMergeResources()'已过时,并已替换为'variant.getMergeResourcesProvider()'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆