Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio doesn't recognize InstanceID class

I want to implement GCM Client on Android. Following the guide here https://developers.google.com/cloud-messaging/android/client
I have downloaded the configuration file and copied the google-services.json file into the app/ directory of the project.

I have also added the dependencies in the project's build.gradle

classpath 'com.google.gms:google-services:1.3.0-beta1'

and plugin in the app level build.gradle

apply plugin: 'com.google.gms.google-services'

I have also included the Google Play Services SDK

compile 'com.google.android.gms:play-services:6.+'

I have also updated the AndroidManifest.xml file as shown here https://developers.google.com/cloud-messaging/android/client

To get the Registration Token, when I use the following code

InstanceID instanceID = InstanceID.getInstance(this);

Android Studio does not recognize the class. I get a "Cannot resolve symbol 'InstaceID'". Any reason as to why this is happening?

like image 757
Sai Manoj Kadiyala Avatar asked Jul 11 '15 03:07

Sai Manoj Kadiyala


3 Answers

Update your Play services SDK to

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

Then clean your Project.

Worked for me. Hope it works for you too!

like image 106
Prashant Solanki Avatar answered Oct 25 '22 22:10

Prashant Solanki


you are missing the gcm

add on your gradle:

compile "com.google.android.gms:play-services-gcm:10.2.6"
like image 6
lucasddaniel Avatar answered Oct 25 '22 21:10

lucasddaniel


Basically, you have to use the latest version of the Google Play Services, Android Support Repository and Google Repository for this to work, and then include the latest version of the Google Play Services

compile 'com.google.android.gms:play-services:7.5.0'
like image 2
Sai Manoj Kadiyala Avatar answered Oct 25 '22 21:10

Sai Manoj Kadiyala