【问题标题】:Error while delivering the message: ServiceIntent not found传递消息时出错:未找到 ServiceIntent
【发布时间】:2016-10-10 16:19:38
【问题描述】:

我正在尝试在我的 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'
}

你能帮我弄清楚并解决它吗?

【问题讨论】:

  • 能否将 build.gradle 依赖项添加到问题中?
  • 我已将 build.gradle 依赖项添加到问题中
  • 你好,你是怎么解决的?
  • 如果你在小米上测试,有时候发不了消息,也可以看看这个回答stackoverflow.com/questions/58109753/…

标签: android service firebase-cloud-messaging amazon-sns firebase-notifications


【解决方案1】:

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

【讨论】:

  • 嘿,我也面临同样的问题。我还没有在我的应用程序中集成 FCM。有什么指点吗?
【解决方案2】:

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

【讨论】:

    【解决方案3】:

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

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

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

    【讨论】:

      【解决方案4】:

      如果您已尝试所有其他解决方案但仍然出现错误,请尝试强制尝试...将以下代码添加到您要求服务或同步地图的代码中。
      在 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 );
      
              }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-12-30
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多