android - 错误 : could not find com. google.gms :google-services:4. 2.0

标签 android firebase android-studio android-gradle-plugin jcenter

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

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()
    }
}

关于android - 错误 : could not find com. google.gms :google-services:4. 2.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53708702/

相关文章:

android - Google Play 服务是否会使我的应用程序的 APK 变大?

android - Android 上的 AR - 区域内的移动

java - 如何修改IDEA/Android Studio设置中 “try-catch”模板的异常变量默认名称?

android - 根据字符串中的数据(如word)更改imageview的显示图像

android - 在 Android 中处理网络上的数据

java - 删除 Android 上的所有照片

javascript - Firebase 断开连接

javascript - Firebase - 如何将 orderBy 添加到复合查询?

android - NoClassDefFoundError : com. 谷歌.firebase.FirebaseOptions

Android 模拟器不会在 Android Studio 中关闭(我在 AVD Manager 的“操作”选项卡下没有看到 "Stop")