【问题标题】:FCM - How to fix android.app.RemoteServiceException: Bad notification posted from package Couldn't expand RemoteViews for: StatusBarNotificationFCM - 如何修复 android.app.RemoteServiceException:从包发布的错误通知无法扩展 RemoteViews:StatusBarNotification
【发布时间】:2018-06-15 21:45:44
【问题描述】:

我看到 1000 多个与通知相关的崩溃报告,但没有可行的方法来调试或检查 Firebase Cloud Messaging 中通知的应用代码

Fatal Exception: android.app.RemoteServiceException: Bad notification posted from package com.appbootup.ipo.news: Couldn't expand RemoteViews for: StatusBarNotification(pkg=com.appbootup.ipo.news user=UserHandle{0} id=2 tag=IPO-SME score=10: Notification(pri=1 contentView=com.appbootup.ipo.news/0x1090064 vibrate=null sound=null defaults=0x0 flags=0x10 kind=[null] 2 actions))
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1509)
   at android.os.Handler.dispatchMessage(Handler.java:110)
   at android.os.Looper.loop(Looper.java:193)
   at android.app.ActivityThread.main(ActivityThread.java:5323)
   at java.lang.reflect.Method.invokeNative(Method.java)
   at java.lang.reflect.Method.invoke(Method.java:515)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:828)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:644)
   at dalvik.system.NativeStart.main(NativeStart.java)

不涉及远程视图,因为我没有自定义远程视图代码。 我正在使用默认通知,并且没有与 RemoteViews notificationView = new RemoteViews() 相关的代码

final Notification.Builder builder = new Notification.Builder(context)
            .setContentTitle(mNotificationTitle)
            .setContentText(mNotificationText)
            .setStyle(new Notification.BigTextStyle().bigText(boldmNotificationLongText))
            .setLargeIcon(largeIcon)
            .setSmallIcon(mNotificationSmallIcon)
            .setPriority(mPriority)
            .setTicker(mNotificationTicker)
            .setContentIntent(pendingIntentView)
            .setAutoCancel(true)
            .addAction(R.drawable.ic_menu_share, SHARE_ACTION, pendingIntentShare)
            .addAction(R.drawable.ic_arrow_forward_black_24dp, VIEW_ACTION, pendingIntentView);

更多参考资料 -

  1. https://github.com/firebase/quickstart-android/issues/394

  2. https://github.com/OneSignal/OneSignal-Android-SDK/issues/263

只有 Kitkat 设备会大量抛出这些 - Android 操作系统版本:4.4.4、4.4.2、4.2.2、4.0.4

【问题讨论】:

  • 你的android目标API是什么?
  • minSdkVersion 16, targetSdkVersion 27, compileSdkVersion 27, buildToolsVersion "27.0.3"
  • 当 USB 调试处于实时状态时,我似乎无法在调试模式下模拟这一点。在很多情况下,即使在另一台设备上发布应用程序测试时,我也看不到这一点。但 crashlytics 表明,每条通知都有数千名用户看到崩溃。
  • 在哪个 Android 版本上可以看到 crashlytics?
  • OS 4(似乎不影响 5,6,7)

标签: android firebase firebase-cloud-messaging


【解决方案1】:

通过更改 Notification 使用的可绘制对象来修复。

.addAction(R.drawable.ic_forward_black_24dp, VIEW_ACTION, pendingIntentView);

R.drawable.ic_forward_black_24dp 不再使用 xml 文件(矢量资源),而是使用 png 文件(图像资源)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-09-18
    • 2014-10-08
    • 1970-01-01
    • 1970-01-01
    • 2018-06-18
    • 1970-01-01
    相关资源
    最近更新 更多