Melvin Melvin - 3 months ago 415
Android Question

GCM Failed to resolve target intent service

I tried to get the GCM push notifications working on my Android 6.0.1 device. Unfortunately I'am running into an error.
The log says:


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


But I'am not using firebase.
So why does the log says something about firebase and why does this error happen?

My AndroidManifest.xml file:

<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>




My GCMListener.class file:

public class GcmListener extends GcmListenerService {

@Override
public void onMessageReceived(String from, Bundle data) {
String message = data.getString("message");

if (from.startsWith("/topics/bewegung")) {
sendNotification(message);
}

}
[...]


google-service.json is already located in /app.

Marvin

[EDIT:]
Got it!
I registered an wrong topic on initial start.
Now its working perfect.

Answer

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"/>

source thread.