where is com.google.android.gcm.GCMBaseIntentService?

百般思念 提交于 2019-12-22 04:11:22

问题


I'm following the tutorial on GCM here http://developer.android.com/guide/google/gcm/gs.html

At point 5 of Step 2, it says:

Add the following intent service: service android:name=".GCMIntentService"

This intent service will be called by the GCMBroadcastReceiver (which is is provided by GCM library), as shown in the next step. It must be a subclass of com.google.android.gcm.GCMBaseIntentService, must contain a public constructor, and should be named my_app_package.GCMIntentService (unless you use a subclass of GCMBroadcastReceiver that overrides the method used to name the service).

However, I can't subclass com.google.android.gcm.GCMBaseIntentService, the import can't be resolved. How do I fix this?


回答1:


You have to install the libraries: http://developer.android.com/guide/google/gcm/gs.html#libs

From the SDK Manager, install Extras > Google Cloud Messaging for Android Library. This creates a gcm directory under YOUR_SDK_ROOT/extras/google/ containing these subdirectories: gcm-client, gcm-server, samples/gcm-demo-client, samples/gcm-demo-server, and samples/gcm-demo-appengine.




回答2:


Download gcm.jar from here and place it in YOUR_PROJECT/app/libs directory and then add compile files('libs/gcm.jar') line in build.gradle file



来源:https://stackoverflow.com/questions/11472496/where-is-com-google-android-gcm-gcmbaseintentservice

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!