传递消息时出错:找不到 ServiceIntent

Error while delivering the message: ServiceIntent not found

我正在尝试在我的 Android 应用程序中将 AWS SNS 推送服务与 FCM 集成。
当我尝试通过 SNS 在线控制台发送推送消息时,我收到此错误日志:

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.

我在网上搜索了一下,发现一个似乎是一个非常受欢迎的答案,有 3 个服务 类 GcmIntentServiceGcmIDListenerServiceRegistrationIntentService.我已将那些 类 和服务添加到我的应用程序中,但我仍然没有收到来自 SNS 的任何推送通知。
我也不确定它是否适合我,因为我不仅使用 FCM 服务,还使用 ​​SNS 服务。

这些是我清单中现有的接收器和服务:

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

关于推送通知。当我通过 SNS 在线控制台发送它时,我收到上面的日志错误,但是当我通过 Firebase 在线控制台发送它时,设备收到推送通知,但我仍然收到此日志,这是第一个以及上面日志的最后几行:

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

build.gradle 依赖关系:

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

你能帮我想清楚并解决吗?

首先你应该在依赖块不在其中之后应用 google-services 插件。此外,我没有看到任何添加 FirebaseInstanceID 的依赖项,因此我不确定为什么会出现该错误。同时使用 FCM 和 GCM 也不是一个好主意,因为同一条消息有多个接收者。使用一个或另一个。这可能就是为什么没有收到 sns 消息的原因。

'implementation'com.google.firebase:firebase-messaging:17.4.0' 添加到依赖项部分的应用级别 build.gradle 文件。

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

如果您尝试了所有其他解决方案但仍然出现错误,请尝试强制尝试...将以下代码添加到您请求服务或获取地图同步的代码中。
在 Oncreate 中尝试添加:

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

        }

添加 firebase 消息传递依赖对我有用

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

请注意,firebase-messaging 依赖于 firebase-analytics