Getting error message “Could not find com.google.gms:google-services:2.0.0-alpha6.”

半世苍凉 提交于 2019-12-13 00:47:29

问题


I am trying google analytic in my project. but found following error message after changing build.gradle file.

Error:Could not find com.google.gms:google-services:2.0.0-alpha6. Searched in the following locations: file:/home/vaibhav/android-studio/gradle/m2repository/com/google/gms/google-services/2.0.0-alpha6/google-services-2.0.0-alpha6.pom file:/home/vaibhav/android-studio/gradle/m2repository/com/google/gms/google-services/2.0.0-alpha6/google-services-2.0.0-alpha6.jar https://repo1.maven.org/maven2/com/google/gms/google-services/2.0.0-alpha6/google-services-2.0.0-alpha6.pom https://repo1.maven.org/maven2/com/google/gms/google-services/2.0.0-alpha6/google-services-2.0.0-alpha6.jar Required by: :MaterialTabs-master:unspecified

where I 1. Add the dependency to your project-level build.gradle:

classpath 'com.google.gms:google-services:2.0.0-alpha6'

2.Add the plugin to your app-level build.gradle:

apply plugin: 'com.google.gms.google-services'

and

  1. add a dependency for Google Play Services. Inside build.gradle add:

compile 'com.google.android.gms:play-services-analytics:8.4.0'

Thanks in advance.


回答1:


I had the same problem as you did, and having looked at Google Analytics Quickstart project linked by Tiem Song's answer the I think you are missing the jcenter() repository as I was.

JCenter is the now the default repository used with Android’s gradle plugin[0], but older projects were created using mavenCentral() as the default repository, which doesn't have any of the google-services.

Your build.gradle should look like.

repositories {
    ...
    jcenter()
}
dependencies {
    ...
    classpath 'com.android.tools.build:gradle:2.0.0-beta6'
    classpath 'com.google.gms:google-services:2.0.0-beta6'
}

(I have also updated the beta version from 5 to 6, but that is just to make the answer as current as possible)

Hope that helps

[0] - http://blog.bintray.com/2015/02/09/android-studio-migration-from-maven-central-to-jcenter/




回答2:


Give the beta5 versions of the dependencies a try:

classpath 'com.android.tools.build:gradle:2.0.0-beta5'
classpath 'com.google.gms:google-services:2.0.0-beta5'

The Google Analytics Quickstart project is a working Android app and includes build.gradle examples.



来源:https://stackoverflow.com/questions/35601704/getting-error-message-could-not-find-com-google-gmsgoogle-services2-0-0-alpha

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!