Google 服务依赖冲突

Google Services dependencies conflicts

我想更新项目中的每个库。现在我的成绩是这样的:

compile "com.google.android.gms:play-services-base:15.0.1"
    compile "com.google.android.gms:play-services-ads:15.0.1"
    compile "com.google.android.gms:play-services-location:15.0.1"
    compile "com.google.android.gms:play-services-identity:15.0.1"
    compile "com.google.android.gms:play-services-analytics:15.0.1"
    compile "com.google.android.gms:play-services-gcm:15.0.1"
    compile "com.google.android.gms:play-services-maps:15.0.1"
    compile 'com.google.android.gms:play-services-auth:15.0.1'
    compile 'com.google.firebase:firebase-core:15.0.1'

我收到错误消息:

Failed to resolve: com.google.android.gms:play-services-analytics:15.0.1

查看时可以看到最新版本的分析服务是16.0.1。所以我这样改成绩:

compile "com.google.android.gms:play-services-base:15.0.1"
    compile "com.google.android.gms:play-services-ads:15.0.1"
    compile "com.google.android.gms:play-services-location:15.0.1"
    compile "com.google.android.gms:play-services-identity:15.0.1"
    **compile "com.google.android.gms:play-services-analytics:16.0.1"**
    compile "com.google.android.gms:play-services-gcm:15.0.1"
    compile "com.google.android.gms:play-services-maps:15.0.1"
    compile 'com.google.android.gms:play-services-auth:15.0.1'
    **compile 'com.google.firebase:firebase-core:16.0.1'**

我遇到错误:

Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 15.0.1.

也许你知道我该如何解决这个问题?

您也需要更新 google services 库。转到您的 App's gradle 主文件并确保它看起来像这样:

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

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.google.gms:google-services:4.0.1'
    }
}

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

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