在项目“应用程序"中,已解决的 Google Play 服

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

问题描述

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

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

在项目app"中,解决了 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.

以下依赖项是直接或直接的项目依赖项具有传递依赖关系,导致艺术 ifact 与问题.-- 项目 'app' 依赖于 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 查看依赖路径神器.此错误消息来自 google-services Gradle插件,在 https://报告问题github.com/google/play-services-plugins 并通过添加禁用googleServices { disableVersionCheck = false }"到您的 b uild.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

项目等级:

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]

从这个列表中你会知道两件事:

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 来自第三方库(pressenger)的另一个.我们对第三方库没有影响,所以这里无所谓.但是对于其他依赖项,我们必须使用正确的版本显式声明它:

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:

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

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

Now the build works again. Happy ending :)

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

上一篇:gradle assemble 和 gradle build 任务有什么区别? 下一篇:RxJavaPlugins 错误找不到类“com.google.devtools.build.

相关文章

最新文章