Tuco
Tuco

Reputation: 1052

Failed to resolve: com.google.android.gms:play-services:9.6.0 when syncing project

I'm trying to use Google Play Services on my Android app to get the device's last known location, but when I try to add the gradle dependency:

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

I get the following error:

A problem occurred configuring project ':app'. Could not resolve all dependencies for configuration ':app:_debugCompile'. Could not find com.google.android.gms:play-services:9.6.0. Searched in the following locations: https://jcenter.bintray.com/com/google/android/gms/play-services/9.6.0/play-services-9.6.0.pom https://jcenter.bintray.com/com/google/android/gms/play-services/9.6.0/play-services-9.6.0.jar file:/home/user/Android/Sdk/extras/android/m2repository/com/google/android/gms/play-services/9.6.0/play-services-9.6.0.pom file:/home/user/Android/Sdk/extras/android/m2repository/com/google/android/gms/play-services/9.6.0/play-services-9.6.0.jar file:/home/user/Android/Sdk/extras/google/m2repository/com/google/android/gms/play-services/9.6.0/play-services-9.6.0.pom file:/home/user/Android/Sdk/extras/google/m2repository/com/google/android/gms/play-services/9.6.0/play-services-9.6.0.jar

Does anyone know how to fix this? Thanks!

EDIT

Here's my build.gradle file:

    apply plugin: 'com.android.application'

    android {
        compileSdkVersion 24
        buildToolsVersion "24.0.2"

        defaultConfig {
            applicationId "app"
            minSdkVersion 16
            targetSdkVersion 24
            versionCode 1
            versionName "1.0"
        }


        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }

        lintOptions {
            abortOnError false
        }
    }

    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        testCompile 'junit:junit:4.12'
        compile 'com.android.support:appcompat-v7:24.2.0'
        compile group: 'com.google.code.gson', name: 'gson', version: '2.7'
        compile 'com.squareup.okhttp3:okhttp:3.4.1'
        compile group: 'org.powermock', name: 'powermock-mockito-release-full', version: '1.6.4'
        compile 'org.mockito:mockito-core:1.10.19'
        compile 'com.google.android.gms:play-services:9.6.0'
    }

Upvotes: 1

Views: 1288

Answers (3)

Ibrahim Ali Khan
Ibrahim Ali Khan

Reputation: 92

In your project level build.gradle file, under buildscript > dependencies, classpath 'com.google.gms:google-services:3.0.0'

Upvotes: 0

Prashant Pandey
Prashant Pandey

Reputation: 11

This could be happening due to google play services SDK not being installed in your android studio package. Follow the Android Developers guide on how to set up google play services in your application. There is a link in it to facilitate on how to set up SDK before you add the dependencies in your package.
Google Developers Guide : Google Play services setup

Upvotes: 0

fluffyBatman
fluffyBatman

Reputation: 6704

Update your SDK's Android Support Repository and Google Play services first. See if it syncs after.

Upvotes: 2

Related Questions