8

I have a problem since I upgraded my Android Studio to 3.0.0 : I cannot find com.google.android.gms:play-services anymore!

After adding this dependency, when I try to sync my project I get this message :

Failed to resolve: com.google.android.gms:play-services-games:11.4.2

I can click on "Install repository and sync project" but when I do, I get this message :

Could not find dependency "com.google.android.gms:play-services-games:11.4.2"

I tried to search, but the only solutions I found was to install Google repository, and add jcenter() to the repositories in my build.gradle file But I already did that!

Any idea?

Here is my build.gradle file :

buildscript {


    repositories {
        mavenLocal()
        mavenCentral()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0'
        classpath 'com.mobidevelop.robovm:robovm-gradle-plugin:2.3.1'


    }
}

allprojects {
    apply plugin: "eclipse"
    apply plugin: "idea"

    version = '1.0'
    ext {
        appName = "Glowee"
        gdxVersion = '1.9.7'
        roboVMVersion = '2.3.1'
        box2DLightsVersion = '1.4'
        ashleyVersion = '1.7.0'
        aiVersion = '1.8.0'
    }

    repositories {
        mavenLocal()
        mavenCentral()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        maven { url "https://oss.sonatype.org/content/repositories/releases/" }
    }
}

project(":desktop") {
    apply plugin: "java"


    dependencies {
        compile project(":core")
        compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
        compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"

    }
}

project(":android") {
    apply plugin: "android"

    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-arm64-v8a"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
        compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"

        natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi"
        natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a"
        natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a"
        natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
        natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64"

        compile "com.google.android.gms:play-services-games:11.4.2"
        compile "com.google.android.gms:play-services-ads:11.4.2"
        compile "com.google.android.gms:play-services-plus:11.4.2"

    }
}

project(":ios") {
    apply plugin: "java"
    apply plugin: "robovm"


    dependencies {
        compile project(":core")
        compile "com.mobidevelop.robovm:robovm-rt:$roboVMVersion"
        compile "com.mobidevelop.robovm:robovm-cocoatouch:$roboVMVersion"
        compile "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"

        compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-ios"

    }
}

project(":core") {
    apply plugin: "java"


    dependencies {
        compile "com.badlogicgames.gdx:gdx:$gdxVersion"

        compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"

    }
}

tasks.eclipse.doLast {
    delete ".project"
}
Sushin Pv
  • 1,563
  • 2
  • 19
  • 33
Xavier P
  • 315
  • 1
  • 3
  • 12
  • Have you added the `google()` repository? https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html#update_gradle – Kuffs Oct 26 '17 at 12:11
  • I just did! I added it under the jcenter() repository, but I still get the same error – Xavier P Oct 26 '17 at 12:14
  • See this: https://developer.android.com/studio/build/dependencies.html#google-maven – Kuffs Oct 26 '17 at 12:16
  • https://stackoverflow.com/questions/30811608/could-not-find-com-google-android-gmsplay-services7-3-0 – Anil Oct 26 '17 at 12:25
  • Ok I fixed it! I was adding the google() repository in the buildscript scope, I deplaced it to the allprojects scope and now it works, thank you! – Xavier P Oct 26 '17 at 12:35

3 Answers3

15

i fixed the issue by adding google() repository in build.gradle project module

enter image description here

Saranjith
  • 9,547
  • 2
  • 55
  • 102
other Tall guy
  • 331
  • 2
  • 8
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/low-quality-posts/17861778) – Saranjith Nov 07 '17 at 07:19
  • I attached the screenshot of my Project Build Gradle . That's all . And he needs to do is just add "google()" this in the repositories { } and that is what the screenshot tells(or how I implemented) It is a link to the imgur that's all @Saranjith – other Tall guy Nov 07 '17 at 08:51
  • 9
    I have this problem, and I have `google()` in my repositories. – salmanseifian Apr 24 '18 at 16:15
  • @SalmanSeifian put google() in the first line, before jcenter() – Borja Aug 22 '19 at 07:03
6

I had the same issue, i fix it by adding google() repository in build.gradle project module

sabith.ak
  • 190
  • 2
  • 11
0

I tried with 'google()' but it didnt work, reading some suggestions of AndroidStudio I found out that to solve this I had to modify manually the build.gradle file upgrading the compileSdkVersion, minSdkVersion, etc ... I guess that the problem came out because I was using something that wasnt compatible with the minSdkVersion that I had.

Steven_95
  • 75
  • 7