-1

I am integrating GCM to a project using Android Studio for that I am adding google play service dependencies to top level gradle as below snippet code:

dependencies {
    classpath 'com.android.tools.build:gradle:1.3.0'
    classpath 'com.google.gms:google-services:1.5.0-beta2'  //this one
}

But I am getting error Failed to find: com.google.android.gms:play-services-gcm:8.3.0 and Failed to find: com.google.android.gms:play-services-measurement:8.3.0. I have updated the goole play service from SDK manager and sync the project.

I have added apply plugin: 'com.google.gms.google-services' in top-level gradle also but its still showing same error

Pankaj
  • 7,908
  • 6
  • 42
  • 65
  • add `apply plugin: 'com.google.gms.google-services'` in project level gradle – M D Dec 11 '15 at 09:39
  • I have done that also – Pankaj Dec 11 '15 at 09:39
  • and are you adding any play service library to your project ?? – Sree Dec 11 '15 at 09:45
  • Can u try as explained here http://stackoverflow.com/questions/30527369/error-could-not-find-com-google-gmsgoogle-services1-0-when-adding-google-ser – Raghavendra Dec 11 '15 at 09:47
  • @Sree - nope i am trying to integrating google play service – Pankaj Dec 11 '15 at 09:48
  • @Raghavendra - the link you have given is for different issue its not the same issue. – Pankaj Dec 11 '15 at 09:49
  • i have the same issue, better you download lay service library and add as a module then set references, NOTE : do't forgot to build gradle for play service library. and add in your gradle file, it will work – Sree Dec 11 '15 at 09:51
  • @Sree - that is what i am asking what should i have to add in gradle??? I have tried to use `compile com.google.android.gms:play-services-gcm:8.1.0` but wouldn't help me out – Pankaj Dec 11 '15 at 09:53
  • Do you know how to add a dependency in android Studio ? – Sree Dec 11 '15 at 09:56
  • @Sree- What you think ?? – Pankaj Dec 11 '15 at 09:58
  • Really i am sorry, i dot know what is your problem, I had the same issue, i resolved it by adding play services library as module in to my project and set that as dependency – Sree Dec 11 '15 at 09:59
  • and do your updated classpath 'com.google.gms:google-services:1.5.0-beta2' with *'classpath 'com.google.gms:google-services:1.5.0''* – Sree Dec 11 '15 at 10:01
  • Google official document showing `classpath 'com.google.gms:google-services:1.5.0-beta2'` you can check [here](https://developers.google.com/cloud-messaging/android/client) – Pankaj Dec 11 '15 at 10:11
  • 1
    com.google.gms:google-services:1.5.0 is out that i am sure – Sree Dec 11 '15 at 10:32

2 Answers2

1

You dont need to reference the full google play services just add the GCM reference to the build.gradel module.

this is what mine looks like and works fine.

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.2.1'
    compile 'com.google.android.gms:play-services-gcm:7.8.0'
}

then make sure you run the build.grade. the version may have also changed since i added mine.

Also note you are putting it into the wrong gradel file, use the module not the top one

Rob85
  • 1,719
  • 1
  • 23
  • 46
0

Please make sure you have latest Android Studio installed, along with updated Google Play Services. It can also be a cause of error mentioned. Moreover, you don't need to add plugin line apply plugin: 'com.google.gms.google-services' as well. It will compile fine without it. Currently, I am using Android Studio 2.1 and gradle version 2.10 to compile following gradle configuration.

Build.gradle (Project Level)

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.0-alpha3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.google.gms:google-services:2.0.0-alpha6'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Build.gradle (app Module)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "your.package.id.here"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.google.android.gms:play-services-gcm:8.4.0'
   }
NightFury
  • 13,436
  • 6
  • 71
  • 120