问题描述
我看到与通知相关的崩溃报告数以千计,而没有可行的方法来调试或检查Firebase Cloud Messaging中通知的应用程序代码
I am seeing 1000s of crash reports related to notification with no viable way to debug or check app code for notifications in 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不涉及,因为我没有自定义的远程视图代码.我正在使用默认通知,并且没有与RemoteViews notificationView = new RemoteViews()相关的代码
RemoteViews are not involved as i do not have custom remote view code.I am using default notification and have no code related to 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);
更多参考-
https://github.com/OneSignal/OneSignal-Android -SDK/issues/263
只有Kitkat设备大量投放这些设备-Android操作系统版本:4.4.4、4.4.2、4.2.2、4.0.4
Only Kitkat Devices are throwing these in large numbers - Android OS version: 4.4.4, 4.4.2, 4.2.2, 4.0.4
推荐答案
通过更改Notification所使用的可绘制对象来解决.
Fixed by changing the drawable used by Notification .
.addAction(R.drawable.ic_forward_black_24dp, VIEW_ACTION, pendingIntentView);
R.drawable.ic_forward_black_24dp 不再使用xml文件(矢量资产),而现在我们使用png文件(图像资产).
R.drawable.ic_forward_black_24dp no longer uses xml file (Vector Asset) and instead we now use png file (Image Asset).
这篇关于FCM-如何修复android.app.RemoteServiceException:从程序包中发布的错误通知无法针对以下对象展开RemoteViews:StatusBarNotification的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!