在项目“应用"中,已解析的Google Play服务库依赖项依赖于另一个版本 [英] In project 'app' a resolved Google Play services library dependency depends on another at an exact version

查看:651
本文介绍了在项目“应用"中,已解析的Google Play服务库依赖项依赖于另一个版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试使用FireStore和Google身份验证创建一个简单的应用程序. gradle有问题:

Trying to create a simple app with FireStore and Google Authentication. Having problem with the gradle:

在项目应用"中,已解决的Google Play服务库依赖性 取决于另一个版本的确切版本(例如"[15.0.1]",但不是 被解析为该版本.图书馆展示的行为将 不为人知.

In project 'app' a resolved Google Play services library dependency depends on another at an exact version (e.g. "[15.0. 1]", but isn't being resolved to that version. Behavior exhibited by the library will be unknown.

依赖项失败:com.google.android.gms:play-services-flags:15.0.1 -> com.google.android.gms:play-services-basement @ [ 15.0.1],但play-services-basement版本为16.0.1.

Dependency failing: com.google.android.gms:play-services-flags:15.0.1 -> com.google.android.gms:play-services-basement@[ 15.0.1], but play-services-basement version was 16.0.1.

以下依赖项是直接或直接的项目依赖项 具有传递依赖,从而导致与 问题. -项目应用"取决于com.google.firebase:firebase-firestore@17.1.5 -项目'app'取决于com.firebaseui:firebase-ui-auth@4.2.0

The following dependencies are project dependencies that are direct or have transitive dependencies that lead to the art ifact with the issue. -- Project 'app' depends onto com.google.firebase:firebase-firestore@17.1.5 -- Project 'app' depends onto com.firebaseui:firebase-ui-auth@4.2.0

有关扩展调试信息,请从命令行使用以下命令执行Gradle ./gradlew --info:app:assembleDebug来查看到的dep endency路径 神器.此错误消息来自google-services Gradle 插件,在https://上报告问题 github.com/google/play-services-plugins并通过添加来禁用 "googleServices {disableVersionCheck = false}"到您的build.gradle 文件.

For extended debugging info execute Gradle from the command line with ./gradlew --info :app:assembleDebug to see the dep endency paths to the artifact. This error message came from the google-services Gradle plugin, report issues at https:// github.com/google/play-services-plugins and disable by adding "googleServices { disableVersionCheck = false }" to your b uild.gradle file.

    apply plugin: 'com.android.application'

    android {
        compileSdkVersion 27
        defaultConfig {
            applicationId "myapp.com"
            minSdkVersion 19
            targetSdkVersion 27
            versionCode 11
            versionName "1.1"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
            multiDexEnabled true
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }

    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation 'com.android.support:appcompat-v7:27.1.1'
        implementation 'com.android.support.constraint:constraint-layout:1.1.3'
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'com.android.support.test:runner:1.0.2'
        androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
        implementation 'com.google.firebase:firebase-firestore:17.1.5'

        implementation 'com.firebaseui:firebase-ui-auth:4.2.0'

    }

    apply plugin: 'com.google.gms.google-services'
    com.google.gms.googleservices.GoogleServicesPlugin

项目gradle:

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'

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

    }
}

有人可以帮我吗?

推荐答案

对于个别解决方案,这里确实有很多答案,但实际上并不能解决问题. 以下是一般解决此问题的方法:

There are many answers here for individual solutions that do not really get down to the problem. Here is how to solve this in general:

如原始日志输出所示,使用以下命令在终端中运行构建很有用:

As the original log output suggests, it is useful to run the build in the terminal with the following command:

./gradlew --info assembleDebug

这将为您提供冲突中涉及的所有依赖项的列表.看起来与此类似(我删除了程序包名称,以使其更具可读性):

This will give you a list of all dependencies that are involved in the conflict. It looks similar to this (I removed the package name stuff to make it a bit more readable):

Dependency Resolution Help: Displaying all currently known paths to any version of the dependency: Artifact(groupId=com.google.firebase, artifactId=firebase-iid)

-- task/module dep -> firebase-analytics@17.2.0
---- firebase-analytics:17.2.0 library depends -> play-services-measurement-api@17.2.0
------ play-services-measurement-api:17.2.0 library depends -> firebase-iid@19.0.0

-- task/module dep -> firebase-core@17.2.0
---- firebase-core:17.2.0 library depends -> firebase-analytics@17.2.0
------ firebase-analytics:17.2.0 library depends -> play-services-measurement-api@17.2.0
-------- play-services-measurement-api:17.2.0 library depends -> firebase-iid@19.0.0

-- task/module dep -> play-services-measurement-api@17.2.0
---- play-services-measurement-api:17.2.0 library depends -> firebase-iid@19.0.0

-- task/module dep -> firebase-iid@19.0.0

-- task/module dep -> firebase-messaging@17.1.0
---- firebase-messaging:17.1.0 library depends -> firebase-iid@[16.2.0]

-- task/module dep -> com.pressenger:sdk@4.8.0
---- com.pressenger:sdk:4.8.0 library depends -> firebase-messaging@17.1.0
------ firebase-messaging:17.1.0 library depends -> firebase-iid@[16.2.0]

从此列表中,您了解2件事:

From this list you get to know 2 things:

  1. 在哪里发现冲突?
  2. 设置了哪些版本的冲突依赖项

在我的情况下,冲突的依赖项是firebase-iid:它是@19.0.0@16.2.0

In my case the conflicting dependency is firebase-iid: It's either @19.0.0 or @16.2.0

要解决此问题,您必须在build.gralde中明确定义错误的firebase-iid的顶级依赖项.

To fix this you must define the top-level dependency of the wrong firebase-iid explicitly in your build.gralde.

因此,在上方的日志中,您可以看到有2个过时版本的firebase-iid@16.2.0的示例.一个来自-- task/module dep -> firebase-messaging@17.1.0,另一个来自第三方库(增压器).我们对第三方库没有影响,因此此处无事可做. 但是对于其他依赖项,我们必须使用正确的版本显式声明它:

So in the upper log you can see that there are 2 examples of an out-dated version of firebase-iid@16.2.0. One comes from -- task/module dep -> firebase-messaging@17.1.0 the other one from a third-party library (pressenger). We don't have influence on the third-party library, so nothing to do here. But for the other dependency, we have to declare it explicitly with the correct version:

implementation 'com.google.firebase:firebase-messaging:20.0.0'

现在,构建可以再次运行.大结局:)

Now the build works again. Happy ending :)

这篇关于在项目“应用"中,已解析的Google Play服务库依赖项依赖于另一个版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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