无法解析目标意图服务,传递消息时发生错误:未找到ServiceIntent [英] Failed to resolve target intent service, Error while delivering the message: ServiceIntent not found

查看:338
本文介绍了无法解析目标意图服务,传递消息时发生错误:未找到ServiceIntent的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我们的服务器发送推送通知时,我的应用程序日志中出现了这两个错误: gcm / p>


E / GcmReceiver(8049):无法解析目标意向服务,跳过
classname enforcement E / GcmReceiver(8049):错误同时提供
消息:ServiceIntent找不到。


在我的应用程序文件夹中,我得到了 google -services.json 文件。



我已将 2所需服务和接收方添加到我的清单:

 < receiver 
android:name =com.google.android.gms.gcm.GcmReceiver
android:exported =true
android:permission =com.google.android.c2dm.permission.SEND>
< intent-filter>
< category android:name =com.myapppackage.application/>
< / intent-filter>
< / receiver>


< service
android:name =com.myapppackage.application.gcm.newgcm.RegisterGCMTokenService
android:exported =false>
< / service>


< service
android:name =com.myapppackage.application.gcm.newgcm.MyInstanceIDListenerService
android:exported =false>
< intent-filter>
< / intent-filter>
< / service>

我有也将这两个添加为java类。并上传到我们的服务器是好的。 我也推出了'事件',但不知何故,我得到了上述2个错误,并且没有任何消息。 项目编号从google api控制台到 strings.xml 作为'google_app_id'



API键应该没问题,因为我确实得到了推送事件,但不知何故提供了该消息。



我的gradle的应用程序级别依赖项包含:
$ b

  compile'c​​om.google.android。 gms:play-services:8. +'

我的gradle的项目级依赖项具有:

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

所以到底是什么?!如果可以,请帮助我。

解决方案

您应该在清单中包含这3个服务。您错过了 com.google.android.c2dm.intent.RECEIVE

 < service 
android:name =com.myapppackage.application.gcm.GcmIntentService
android:exported =false>
< intent-filter>
< / intent-filter>
< / service>

< service
android:name =com.myapppackage.application.gcm.GcmIDListenerService
android:exported =false>
< intent-filter>
< / intent-filter>
< / service>

< service
android:name =com.myapppackage.application.gcm.RegistrationIntentService
android:exported =false/>


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:

  <receiver
        android:name="com.google.android.gms.gcm.GcmReceiver"
        android:exported="true"
        android:permission="com.google.android.c2dm.permission.SEND" >
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <category android:name="com.myapppackage.application" />
        </intent-filter>
    </receiver>


    <service
        android:name="com.myapppackage.application.gcm.newgcm.RegisterGCMTokenService"
        android:exported="false">
    </service>


    <service
        android:name="com.myapppackage.application.gcm.newgcm.MyInstanceIDListenerService"
        android:exported="false">
        <intent-filter>
            <action android:name="com.google.android.gms.iid.InstanceID"/>
        </intent-filter>
    </service>

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.

解决方案

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

    <service
        android:name="com.myapppackage.application.gcm.GcmIntentService"
        android:exported="false">
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
        </intent-filter>
    </service>

    <service
        android:name="com.myapppackage.application.gcm.GcmIDListenerService"
        android:exported="false">
        <intent-filter>
            <action android:name="com.google.android.gms.iid.InstanceID" />
        </intent-filter>
    </service>

    <service
        android:name="com.myapppackage.application.gcm.RegistrationIntentService"
        android:exported="false"/>

这篇关于无法解析目标意图服务,传递消息时发生错误:未找到ServiceIntent的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆