Error while delivering the message: ServiceIntent not found

混江龙づ霸主 提交于 2019-11-28 09:01:30

问题


I'm trying to integrate AWS SNS push services with FCM in my Android app.
When I'm trying to send a push message through SNS online console, I get this error log:

E/FirebaseInstanceId: Failed to resolve target intent service, skipping classname enforcement
E/PushListenerService: From: ************ /* My Sender ID*/
E/PushListenerService: Message: hola
E/FirebaseInstanceId: Error while delivering the message: ServiceIntent not found.

I've searched a bit online, and I found a seemed to be a very popular answer, with 3 services with the classes GcmIntentService, GcmIDListenerService, RegistrationIntentService. I've added those classes and services into my app, but I still don't get any push notifications from SNS.
I also wasn't sure if it is the right solution for me, since I'm not only use FCM Services, but also SNS Services.

These are my existing receivers and services in 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.intap.appme" />
        </intent-filter>
    </receiver>

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

About the push notifications. When I'm sending it through the SNS online console, I get the above log error, but when I'm sending it through the Firebase online console, the device gets the push notification, but I still get this log, which is the first and the last lines of the log above:

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

build.gradle dependencies:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    wearApp project(':wear')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.1.1'
    compile 'com.android.support:design:24.1.1'
    compile fileTree(dir: 'libs', include: ['activation.jar'])
    compile fileTree(dir: 'libs', include: ['additionnal.jar'])
    compile fileTree(dir: 'libs', include: ['mail.jar'])
    compile 'com.amazonaws:aws-android-sdk-core:2.2.18'
    compile 'com.amazonaws:aws-android-sdk-s3:2.2.18'
    compile 'com.amazonaws:aws-android-sdk-ddb:2.2.18'
    compile 'com.amazonaws:aws-android-sdk-ddb-mapper:2.2.18'
    compile 'com.amazonaws:aws-android-sdk-ec2:2.2.18'
    compile 'com.google.android.gms:play-services-plus:9.0.1'
    compile 'com.amazonaws:aws-android-sdk-sns:2.2.18'
    compile 'com.google.android.gms:play-services-gcm:9.0.1'
    compile 'com.android.support:multidex:1.0.1'
    apply plugin: 'com.google.gms.google-services'
}

Could you please help me figure it out and solve it?


回答1:


First you should apply the google-services plugin after the dependency block not in it. Also I'm not seeing any dependency that is adding FirebaseInstanceID so I'm not sure why that error is showing up. Also using FCM and GCM together is not a good idea since you have multiple receivers for the same message. Use one or the other. That could be why the sns messages are not being received.




回答2:


add 'implementation'com.google.firebase:firebase-messaging:17.4.0' in to your app level build.gradle file in dependency section.

dependencies {
    implementation 'com.google.firebase:firebase-core:16.0.7'
    implementation 'com.google.firebase:firebase-database:16.1.0'
    implementation'com.google.firebase:firebase-messaging:17.4.0'
}



回答3:


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




回答4:


If you have tried all other solutions and still getting the error then try forcefully trying it... add the below code to your code where you asked for the service or getting map synced.
inside Oncreate try adding:

 if(ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(yourActivity.this, Manifest.permission.ACCESS_COARSE_LOCATION)!= PackageManager.PERMISSION_GRANTED) {
            ActivityCompat.requestPermissions(yourActivity.this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, LOCATION_REQUEST_CODE);

        }
        else{
            mapFragment.getMapAsync(this);
        }




and inside onConnected method try adding.

if(ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(yourActivity.this, Manifest.permission.ACCESS_COARSE_LOCATION)!= PackageManager.PERMISSION_GRANTED)
        { 
ActivityCompat.requestPermissions(youractivity.this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION},LOCATION_REQUEST_CODE );

        }


来源:https://stackoverflow.com/questions/39962566/error-while-delivering-the-message-serviceintent-not-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!