android - 在项目 'app' 中,已解决的 Google Play 服务库依赖项依赖于另一个确切版本

标签 android android-gradle-plugin firebaseui

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

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.

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.

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

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

项目等级:

buildscript {

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

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

    }
}

有人可以帮帮我吗?

最佳答案

这里有许多针对个别解决方案的答案,但并没有真正解决问题。 这里是解决这个问题的一般方法:

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

./gradlew --info assembleDebug

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

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]

从这个列表中,您可以了解两件事:

  1. 在哪里找到冲突的依赖项
  2. 设置了哪些版本的冲突依赖

在我的例子中,冲突的依赖项是 firebase-iid:它是 @19.0.0@16.2.0

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

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

实现 'com.google.firebase:firebase-messaging:20.0.0'

现在构建再次运行。快乐的结局:)

关于android - 在项目 'app' 中,已解决的 Google Play 服务库依赖项依赖于另一个确切版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54055141/

相关文章:

android - ImageView : scale too large images down, 不要放大太小的图片

android - 如何在android中使用mpchart库设置图表外的矩形框?

android - Gradle 同步连接超时

android - Gradle 多项目 android 库设置与 maven 本地

javascript - Uncaught ReferenceError : firebaseui is not defined

java - Firebase 数据库 : can't download image

android - 问题+澄清 : Sending message from Raspberry Pi to Android Phone using Google cloud Messaging

android - APK list 与 temp/Stagingarea list

android - 查找Android中javaMaxHeapSize的默认值