如何解决错误gradle同步失败其他各种库请求的库?

时间:2018-11-23 08:32:09

标签: android firebase android-studio

我想在我的项目中实现Firestore,但添加以下行后,gradle同步失败

implementation 'com.google.firebase:firebase-firestore:17.1.2'

我收到错误消息

Gradle sync failed: The library com.google.android.gms:play-services-basement is being requested by various other libraries at [[15.0.1,15.0.1]], but resolves to 16.0.1. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.
        Consult IDE log for more details (Help | Show Log) 

此错误是什么以及如何解决 我正在使用的classpath也是

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

3 个答案:

答案 0 :(得分:0)

检查此gradle文件的项目级别

// Top-level build file where you can add configuration options common to all sub-projects/modules.

 buildscript {
ext.kotlin_version = '1.2.30'
repositories {
    google()
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.1.3'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    classpath 'com.google.gms:google-services:4.0.1'
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}

allprojects {
repositories {
    google()
    jcenter()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

答案 1 :(得分:0)

将使用的库降级为控制台中显示的版本。那是

implementation 'com.google.firebase:firebase-firestore:15.0.1'

这是由于版本冲突造成的

答案 2 :(得分:0)

选中此复选框,我只是针对从未进行过测试

的特定问题创建的
 configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.google.firebase') {
            if (!requested.name.startsWith("firebase-firestore")) {
                details.useVersion '17.1.2'
            }
        }

    }
}

在应用gradle文件的defaultConfig标签中添加此图片