我在崩溃日志中看到以下异常:
android.app.RemoteServiceException: Bad notification posted from package com.my.package: Couldn't create icon: StatusBarIcon(pkg=com.my.package user=0 id=0x7f02015d level=0 visible=true num=0 )
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1456)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5487)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
Run Code Online (Sandbox Code Playgroud)
我使用以下方法通过AlarmManager从PendingIntent集中从IntentService发布我的通知.此处传递的所有值都来自PendingIntent/IntentService中的bundle extras.
/**
* Notification
*
* @param c
* @param intent
* @param notificationId
* @param title
* @param message
* @param largeIcon
* @param smallIcon
*/
public static void showNotification(Context c, Intent intent,
int notificationId, String title, String message, int …Run Code Online (Sandbox Code Playgroud) android android-notifications android-resources android-drawable
在过去的 3-4 个月中,我一直在 Crashlytics 中看到这种崩溃,仅适用于具有奥利奥和馅饼的 OnePlus 制造的设备(一个、3、5,5T、6、6T)。以前的android版本没有发生这种情况。
Fatal Exception: android.app.RemoteServiceException: can't deliver broadcast
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1844)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6892)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Run Code Online (Sandbox Code Playgroud)
我在stackoverflow中查看了不同的帖子,重新检查了与Firebase Messaging相关的所有代码并更新到最新版本的firebase,但没有运气。如果有人遇到同样的崩溃,请帮忙。提前致谢。
编辑 1:可能的原因可能是,我将通知图标放在 mipmap 而不是 drawable 中。 https://forums.oneplus.com/threads/app-notification-provokes-continues-system-ui-crashes-and-possible-corruption-of-the-os.713575/
https://issuetracker.google.com/issues/69109923
但是,如果我将通知放在 drawable 中,那么我该如何修复资源 ID,以免再次遇到下面提到的问题(为了修复资源 ID,我将通知图标从 drawable 移到了 mipmap)。最近发布的 gradle 忽略了 public.xml:
如何修复:android.app.RemoteServiceException:从包中发布的错误通知*:无法创建图标:StatusBarIcon
notifications android broadcast android-resources remoteserviceexception