当前位置:  开发笔记 > Android > 正文

错误:找不到com.google.gms:google-services:4.2.0

如何解决《错误:找不到com.google.gms:google-services:4.2.0》经验,为你挑选了4个好方法。

今天我试图将com.google.gms:google-services从4.1.0更新到4.2.0,因为它是最新版本并由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)有任何问题,可以在此处跟踪问题进度.



1> Doug Stevens..:

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

在jCenter上发现了Google Play服务插件,Firebase性能监控插件,exoplayer以及可能的其他依赖项.目前尚不清楚为什么,但已知一些团队正在将他们的构建工件移动到Google maven repo.

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


谢谢你的回答.希望问题尽快解决!

2> 小智..:

由于google-services:4.2.0在Central Repository中不可用,因此需要从Android Tools Repository下载.要将此添加到您的项目添加

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

这到buildcript存储库.有关更多信息,请参阅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()
    }
}


这只是一个短期的解决方案.Google maven repo目前存在问题.它正在调查中.从长远来看,你应该依赖在build.gradle中使用`google()`.

3> Novian Agung..:

试试这个,为我工作:

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
}



4> 小智..:

google-services:4.2.0现在又回到了Google Maven存储库,只需将gradle与默认配置同步即可:

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

推荐阅读
ifx0448363
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有