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

前端 未结 4 1236
予麋鹿
予麋鹿 2020-12-18 19:58

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

相关标签:
4条回答
  • 2020-12-18 20:15

    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

    0 讨论(0)
  • 2020-12-18 20:32

    just check gradle for required updated and then sync you app and run again that's worked for (maybe something wrong in firebase)

    0 讨论(0)
  • 2020-12-18 20:34

    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"/>
    
    0 讨论(0)
  • 2020-12-18 20:37

    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

      <service android:name="com.mypackage.application.services.MyGcmListenerService"
            android:exported="false" >
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
        </intent-filter>
        </service>
    
    0 讨论(0)
提交回复
热议问题