How to import GcmListenerService into android studio?

I am creating a GoogleCloudMessaging Android application. I found a lot that the "GcmListenerService" is used, and the old "GCMIntentService" method is now deprecated. I have already installed the Google Play service and will add it to the dependency. But when I try to import

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

it gives the error "cannot resolve character". How to import a class? I link to 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 keep track of things, but still unable to solve the problem.

+4
source share
2 answers

If you’ve already added Google Play services to your dependencies, the problem may be its version.

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

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

Then sync your project.

+6
source

You must enable

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

in the build.gradle file.

+2
source

All Articles