Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import GcmListenerService in android studio?

I am creating android application 'GoogleCloudMessaging'. I Have found many that 'GcmListenerService' is being used and the old method 'GCMIntentService' is now deprecated. I have already install the Google Play service and add it into the dependency. But when i try to import

 import com.google.android.gms.gcm.GcmListenerService;

it gives error "cannot resolve symbol." How can I import the Class? I refer https://developers.google.com/android/reference/com/google/android/gms/gcm/GoogleCloudMessaging and https://developers.google.com/android/reference/com/google/android/gms/gcm/GcmListenerService.html#GcmListenerService() and follow the things but still unable to solve the problem.

like image 272
Hussainsoni Avatar asked Feb 09 '23 10:02

Hussainsoni


2 Answers

If you have already added Google Play Services to your dependencies, the issue might be its version.

Try to update the line(in your build.gradle) to:

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

Then sync your project.

like image 141
Mateus Gondim Avatar answered Feb 20 '23 16:02

Mateus Gondim


You must include

compile 'com.google.android.gms:play-services-gcm:11.0.4'

in your build.gradle file.

like image 24
Şafak Gezer Avatar answered Feb 20 '23 16:02

Şafak Gezer