Error: could not find com.google.gms:google-services:4.2.0

Error: could not find com.google.gms:google-services:4.2.0

今天我试图将 com.google.gms:google-services 从 4.1.0 更新到 4.2.0,因为它是最新版本,recommended 通过 firebase。但是我得到这个错误:

Could not find com.google.gms:google-services:4.2.0.
Searched in the following locations:
    https://jcenter.bintray.com/com/google/gms/google-services/4.2.0/google-services-4.2.0.pom
    https://jcenter.bintray.com/com/google/gms/google-services/4.2.0/google-services-4.2.0.jar
    https://dl.google.com/dl/android/maven2/com/google/gms/google-services/4.2.0/google-services-4.2.0.pom
    https://dl.google.com/dl/android/maven2/com/google/gms/google-services/4.2.0/google-services-4.2.0.jar
    https://maven.fabric.io/public/com/google/gms/google-services/4.2.0/google-services-4.2.0.pom
    https://maven.fabric.io/public/com/google/gms/google-services/4.2.0/google-services-4.2.0.jar
Required by:
    project :

这是我项目的构建 gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        jcenter()
        google()
        maven {
            url 'https://maven.fabric.io/public'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath 'com.google.gms:google-services:4.2.0'

        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
        classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
        // These docs use an open ended version so that our plugin
        // can be updated quickly in response to Android tooling updates

        // We recommend changing it to the latest version from our changelog:
        // https://docs.fabric.io/android/changelog.html#fabric-gradle-plugin
        classpath 'io.fabric.tools:gradle:1.27.0'
    }
}

allprojects {
    repositories {
        jcenter()
        maven {
            url 'https://maven.google.com/'
        }
        google()
    }
}

更新:

正如 Doug Stevenson 所说的那样,依赖关系现在已经建立 运行 所以只需在您的存储库中使用 google() 即可。

如果您对其他 google 存储库(firebase、exoplayer)有任何问题,您可以跟踪问题进度 here

因为google-services:4.2.0在Central Repository中没有,所以需要从Android Tools Repository下载。要将其添加到您的项目中,请添加

maven { url 'https://dl.bintray.com/android/android-tools' }

这是构建脚本存储库。有关更多信息,请参阅 https://mvnrepository.com/artifact/com.google.gms/google-services/4.2.0

buildscript {
    repositories {
        jcenter()
        google()
        maven {
            url 'https://maven.fabric.io/public'
        }
        //  Add this to your project 
        maven { url 'https://dl.bintray.com/android/android-tools' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath 'com.google.gms:google-services:4.2.0'

        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
        classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
        // These docs use an open ended version so that our plugin
        // can be updated quickly in response to Android tooling updates

        // We recommend changing it to the latest version from our changelog:
        // https://docs.fabric.io/android/changelog.html#fabric-gradle-plugin
        classpath 'io.fabric.tools:gradle:1.27.0'
    }
}

allprojects {
    repositories {
        jcenter()
        maven {
            url 'https://maven.google.com/'
        }
        google()
    }
}

试试这个,对我有用:

buildscript {
    repositories {
        google()
        //jcenter()
        jcenter {url 'https://dl.bintray.com/android/android-tools'}
        jcenter {url 'https://firebase.bintray.com/gradle'}
        mavenCentral ()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath 'com.google.gms:google-services:4.2.0'
        classpath 'com.google.firebase:firebase-plugins:1.1.5'
    }
}

allprojects {
    repositories {
        google()
        //jcenter()
        jcenter {url 'https://dl.bintray.com/android/android-tools'}
        jcenter {url 'https://firebase.bintray.com/gradle'}
        mavenCentral ()

    }
}

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

2018 年 12 月 10 日星期一,1:30PM 太平洋标准时间

Google Play 服务插件、Firebase 性能监控插件、exoplayer 和其他可能的依赖项被发现在 jCenter 上丢失。原因尚不清楚,但已知一些团队正在将他们的构建工件移至 Google maven 存储库。

截至目前,Google Play 服务插件已迁移,现在应该可以通过构建脚本中的 google() 使用。

google-services:4.2.0 现在回到 google maven 存储库,只需将 gradle 与默认配置同步:

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