首页 > 解决方案 > 如何解决错误 gradle sync 使其他各种库请求的库失败?

问题描述

我想在我的项目中实现 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 'com.google.gms:google-services:4.1.0'

标签: androidfirebaseandroid-studio

解决方案


检查此 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
}

推荐阅读