Android GCM无法解析目标意图服务
我试图让GCM推送通知在我的Android 6.0.1设备上运行。不幸的是,我遇到了一个错误。 日志上写着: E/FirebaseInstanceId:无法解析目标意图服务,跳过类名强制 E/FirebaseInstanceId:传递消息时出错:未找到ServiceIntent 但我没有使用firebase。 那么为什么日志会提到firebase,为什么会发生这种错误呢 我的AndroidManifest.xml文件:Android GCM无法解析目标意图服务,android,android-intent,firebase,google-cloud-messaging,Android,Android Intent,Firebase,Google Cloud Messaging,我试图让GCM推送通知在我的Android 6.0.1设备上运行。不幸的是,我遇到了一个错误。 日志上写着: E/FirebaseInstanceId:无法解析目标意图服务,跳过类名强制 E/FirebaseInstanceId:传递消息时出错:未找到ServiceIntent 但我没有使用firebase。 那么为什么日志会提到firebase,为什么会发生这种错误呢 我的AndroidManifest.xml文件: <manifest xmlns:android="http://sch
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.push.test">
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:name="com.push.test.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.push.test.permission.C2D_MESSAGE" />
<application
[...] >
<activity android:name=".MainActivity">
[...]
</activity>
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter android:priority="1000">
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.push.test" />
</intent-filter>
</receiver>
<!-- [START gcm_listener] -->
<service
android:name=".GcmListener"
android:exported="false" >
<intent-filter android:priority="1000">
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
<!-- [END gcm_listener] -->
<!-- [START instanceId_listener] -->
<service
android:name=".InstanceListener"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.gms.iid.InstanceID"/>
</intent-filter>
</service>
<!-- [END instanceId_listener] -->
<service
android:name=".RegistrationIntentService"
android:exported="false">
</service>
</application>
google-service.json已位于/app中
马文
[编辑:]
知道了!
我在开始时注册了一个错误的主题。
现在它工作得很好。您的清单中应该有这3项服务。您缺少了一个带有actioncom.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"/>
你能收到通知吗?@SohailZahid我能注册我的应用程序并订阅主题,但收到通知时会抛出上述错误。请不要接受我的答案,以便我可以删除,因为它不是正确的答案,不会帮助其他人,反而会混淆他们。@EugenPechanec不是解决方案,但给了我改进的想法,我认为这是一个常见的错误。然后发布你自己的答案,并标记为已接受。你能想象如果每个人都这么做吗?这不是问题的答案。
<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"/>