Failed to resolve target intent service, Error while delivering the message: ServiceIntent not found

匿名 (未验证) 提交于 2019-12-03 02:03:01

问题:

I try to make gcm work.

When our server sends a push notification I got these two errors in my app's log:

E/GcmReceiver(8049): Failed to resolve target intent service, skipping classname enforcement E/GcmReceiver(8049): Error while delivering the message: ServiceIntent not found.

In my app's folder I got the google-services.json file.

I have added the 2 needed services and the receiver to my Manifest:

  

I have also added these two as java classes. The gcm token providing and uploading to our server's is fine. I also got the push 'event' but somehow I got those 2 errors above, and no messages.

I have added my project number from google api console to strings.xml as 'google_app_id'

The API keys should be all right because I do get the push event, but somehow the message is not provided.

My gradle's app level dependencies have:

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

My gradle's project level dependencies have:

classpath 'com.google.gms:google-services:1.3.1'

So what the heck?! Please help me if you can.

回答1:

You should have these 3 services in your manifest. You're missing the one with the action com.google.android.c2dm.intent.RECEIVE

    


回答2:

Hey You need to add MyGcmListenerService class for receive notification:

public class MyGcmListenerService extends GcmListenerService {  @Override public void onMessageReceived(String from, Bundle data) {     String message = data.getString("message"); }

you need add this class as service in AndroidMaifest.xml

  


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