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

查看:45
本文介绍了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' 可以解决这个问题.但是我使用最新的谷歌服务插件,如果没有它,我显然无法使用任何与 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.

推荐答案

Google 服务 Gradle 插件 (4.3.0 & 4.3.1) 导致此问题,将版本升级到 4.3.2 似乎解决了这个问题;

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 -> 下;依赖,检查你是否有这一行

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天全站免登陆