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
compile 'com.google.android.gms:play-services-analytics:8.4.0'
Thanks in advance.
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/
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.