Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 705
Adam Varhegyi Avatar asked Mar 21 '16 13:03

Adam Varhegyi


2 Answers

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"/>
like image 141
Malek Hijazi Avatar answered Sep 22 '22 00:09

Malek Hijazi


Adding firebase messaging dependency worked for me

implementation 'com.google.firebase:firebase-analytics:17.0.1'
implementation 'com.google.firebase:firebase-messaging:19.0.1'

Please note that firebase-messaging have a dependency on firebase-analytics

like image 39
Omkar Nagare Avatar answered Sep 23 '22 00:09

Omkar Nagare