12

I try to repair the dependency to google play services in my android project. It already worked but now it is broken. I think this happened in between the Android Studio beta- and release-version.

This is the dependency in the build.gradle file:

dependencies {
    compile 'com.google.android.gms:play-services:6.5.87'
}

Android Studio was able to autocomplete the version string: '6.5.87' So I thought it knows how to solve the dependency. But it does not.. This is what I treid:

  • reinstaled Android Studio (1.0.1) and the Android SDK
  • used several play-service versions (incl. tried to use '+')
  • tried to 'gradlew clean' the project
  • installed almost everything from the Android SDK Manager. (incl. Google Repository and Android Support Repository)
  • set all environment variables to the correct path

But I still get this error if I try to do a gradle project sync:

Error:Could not find com.google.android.gms:play-services:6.5.87. Searched in the following locations: file:/C:/Users/MyName/.m2/repository/com/google/android/gms/play-services/6.5.87/play-services-6.5.87.pom file:/C:/Users/MaName/.m2/repository/com/google/android/gms/play-services/6.5.87/play-services-6.5.87.jar https://repo1.maven.org/maven2/com/google/android/gms/play-services/6.5.87/play-services-6.5.87.pom https://repo1.maven.org/maven2/com/google/android/gms/play-services/6.5.87/play-services-6.5.87.jar https://oss.sonatype.org/content/repositories/snapshots/com/google/android/gms/play-services/6.5.87/play-services-6.5.87.pom https://oss.sonatype.org/content/repositories/snapshots/com/google/android/gms/play-services/6.5.87/play-services-6.5.87.jar https://oss.sonatype.org/content/repositories/releases/com/google/android/gms/play-services/6.5.87/play-services-6.5.87.pom https://oss.sonatype.org/content/repositories/releases/com/google/android/gms/play-services/6.5.87/play-services-6.5.87.jar Required by: code:android:1.0

UPDATE:

Gradle is searching in "file:/C:/Users/MyName/.m2/repository/" but it should use "file:/C:/Users/MyName/AppData\Local\Android\sdk\extras\google\m2repository" .. I dont know why this is wrong and how to fix it..

UPDATE 2

I fixed it using this workaround:

repositories {
    def androidHome = System.getenv("ANDROID_HOME")
    maven { url "$androidHome/extras/android/m2repository/" }
    maven { url "$androidHome/extras/google/m2repository/"}
}

But I am not happy with it. Does anybody know whats wrong with my gradle?

Luca Hofmann
  • 1,442
  • 2
  • 14
  • 26
  • This is odd because based on the error message it's not even looking in the SDK for the library, which it should -- it's in the sdk/extras/google/m2repository directory. I tried misconfiguring my project a few different ways and couldn't reproduce this situation, but you may want to double check that it knows where its SDK is. – Scott Barta Dec 18 '14 at 18:11
  • Yes.. this is the error.. Do not know how to solve it :( – Luca Hofmann Dec 18 '14 at 18:13
  • have a look here: http://stackoverflow.com/questions/17155475/could-not-find-com-google-android-gmsplay-services3-1-59-3-2-25-4-0-30-4-1-32/17157227#17157227 – ligi Dec 19 '14 at 10:49
  • I already read this post while investigation.. I dont have multiple SDK's installed and "set all environment variables to the correct path" – Luca Hofmann Dec 19 '14 at 12:59

3 Answers3

15

In Android SDK Manager download the "Google Repository"

Alex Kutsko
  • 1,129
  • 11
  • 9
  • i had same problem with com.android.support:support , after install Android Support Repository worked as well.. – mariomol Nov 13 '15 at 16:49
  • This is the solution. The package can be found under the "Extras" subfolder at the bottom. you can launch the manager from the command line if you simply type `android` – the_5imian Aug 27 '16 at 06:49
2

Try download the sdk and use this library

compile 'com.google.android.gms:play-services:7.0.0'
gmendes
  • 117
  • 1
  • 1
  • 17
2

After adding jcenter() to reposetories or top level gradle file I fixed the issue

    buildscript {
        repositories {
            jcenter()
            mavenCentral()
        }

        dependencies {
            classpath 'com.android.tools.build:gradle:1.0.1'
            classpath 'com.google.gms:google-services:1.5.0-beta2'
        }
    }