15

I'm trying to update an old project that uses GMS libraries. However, Gradle sync fails to refresh the project, giving the error mentioned in the title.

This is what the build.gradle looks like:

project(":android") {
    apply plugin: "android"
    apply plugin: 'com.android.application'

    configurations { natives }

    dependencies {
        compile project(":core")
        compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
        compile "com.google.android.gms:play-services:7.0.0"
    }
}

And the error is:

Error:Could not find com.google.android.gms:play-services:7.0.0.
Searched in the following locations:
    file:/C:/Users/Harri/.m2/repository/com/google/android/gms/play-services/7.0.0/play-services-7.0.0.pom
    file:/C:/Users/Harri/.m2/repository/com/google/android/gms/play-services/7.0.0/play-services-7.0.0.jar
    https://repo1.maven.org/maven2/com/google/android/gms/play-services/7.0.0/play-services-7.0.0.pom
    https://repo1.maven.org/maven2/com/google/android/gms/play-services/7.0.0/play-services-7.0.0.jar
    https://oss.sonatype.org/content/repositories/snapshots/com/google/android/gms/play-services/7.0.0/play-services-7.0.0.pom
    https://oss.sonatype.org/content/repositories/snapshots/com/google/android/gms/play-services/7.0.0/play-services-7.0.0.jar
    https://oss.sonatype.org/content/repositories/releases/com/google/android/gms/play-services/7.0.0/play-services-7.0.0.pom
    https://oss.sonatype.org/content/repositories/releases/com/google/android/gms/play-services/7.0.0/play-services-7.0.0.jar
Required by:
CarGame-refresh:android:1.2

I've installed and updated all the required stuff in the SDK manager:

enter image description here

It should be noted that this project was originally an Eclipse project which I imported to Android Studio just now.

EDIT: It seems that Gradle doesn't look the correct directory for GMS. It's installed in the SDK path, though. It seems that the problem here is very similar to this unsolved question.

Community
  • 1
  • 1
manabreak
  • 5,415
  • 7
  • 39
  • 96
  • Please check if folder 7.0.0 is present in Sdk/extras/Google/m2repository/com/Google/android/gms/play-services. If not, provide a matching folder version. Do u have multiple sdks? – kiranpradeep Mar 22 '15 at 10:35
  • @Kiran The folder is present, and I have just the one SDK installed. – manabreak Mar 22 '15 at 11:46
  • 1
    Try this: Firstly remove the compile code in **build.gradle** file then go to **File => Project** Structure and select app, then select the Dependencies tab. Now you see the libraries that you are currently using, click on the + icon then choose file dependency and find the .jar file :D **btw I'm not sure whether this will work or not :D ** – edwinj Mar 22 '15 at 22:50
  • @edwinj I'd rather use the Gradle support so I could get the updates automatically as new versions are released. For now, I'm using the exact same workaround as the guy in the other SO post I linked. – manabreak Mar 23 '15 at 08:38
  • 1
    The way i showed you also uses gradle, its just a way to add libraries using a UI. When you add libraries that way, it automatically ads the code to the build.gradle file in the background :D if you look at [this](http://www.exoguru.com/android/tools/android-studio/getting-started-with-android-studio.html) tutorial it shows you how to add libraries to build.gradle by code and by using UI. – edwinj Mar 23 '15 at 12:48
  • Make doubly sure that your project is really pointing to the correct sdk location on your drive, as explained in this answer: http://stackoverflow.com/a/16582792/2464728 – Matej Apr 22 '15 at 20:48

5 Answers5

18

It turns out the documentation might be more ahead than what is officially available.

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

Seems to work fine only because I did the following steps:

Open Module Settings(F12) -> Dependencies Tab -> "+" sign -> 1) Library Dependency -> com.google.android.gms:play-services:6.5.87

Mark Lapasa
  • 1,644
  • 4
  • 19
  • 37
  • Good to know. However, I tried a couple of different versions, and none of them worked. In a different project, I got the 7.0.0 version working out of the box, so it must be a Gradle / Android Studio problem. – manabreak Mar 26 '15 at 13:59
  • 1
    I used the android sdk manager to update my google-play-services to revision 23, which seems to include the 7.0.0 library. – crowne Apr 06 '15 at 19:33
17

To use Google Play Services version 7.0.0, you will need to update the Google Play Services and the Google Repository to Rev. 23 & 16 respectively in the Extras section within Android SDK Manager.

To open the Android SDK Manager in Android Studio, go to Tools -> Android -> SDK Manager.

Edit: You will also have to update your SDK Tools to Rev. 24.1.2, SDK Platform Tools to Rev. 22 and optionally the SDK Build Tools to Rev. 22.0.1 from the Tools section in the SDK Manager.

Hassaan
  • 932
  • 8
  • 16
  • 1
    'com.google.android.gms:play-services:7.0.0' will still not work with the updated version 23 & 16 – moberme Apr 23 '15 at 17:21
  • 1
    @moberme: Which IDE and build tools version are you using to build your app? You might have to update your `SDK Tools` to Rev. 24.1.2, `SDK Platform Tools` to Rev. 22 and optionally the `SDK Build Tools` to Rev. 22.0.1 from the Tools section in the SDK Manager. This should allow Gradle to compile version 7 of Google Play Services successfully. – Hassaan Apr 23 '15 at 20:56
2

Firstly update the Android SDK tools, Android SDK Build Tools, Android SDK platform-tools.

Then update Google Play Services and Google Repository from SDK Manager. They are present in Extras section in SDK manager.

This worked for me.

Swapnil Kale
  • 2,620
  • 2
  • 23
  • 21
1

You should use 6.5.87 instead of 7.0.0.

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.google.android.gms:play-services-maps:6.5.87'
    compile 'com.google.android.gms:play-services-drive:6.5.87'
}
Langusten Gustel
  • 10,917
  • 9
  • 46
  • 59
Binh Le
  • 343
  • 2
  • 10
0

You need just to add this line to your dependencies and rebuild your project: compile 'com.google.android.gms:play-services:6.5.87'

issam
  • 697
  • 1
  • 9
  • 15