The crash info is :
android.app.RemoteServiceException: Bad notification posted from package com.xx.xx:
Couldn't create icon: StatusBarIcon(pkg=com.xx.xx user=0 id=0x7f02035c level=0 visible=true num=0 )
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1372)
android.os.Handler.dispatchMessage(Handler.java:102)
android.os.Looper.loop(Looper.java:136)
android.app.ActivityThread.main(ActivityThread.java:5139)
java.lang.reflect.Method.invokeNative(Native Method)
java.lang.reflect.Method.invoke(Method.java:515)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:796)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:612)
dalvik.system.NativeStart.main(Native Method)
I think the problem is can not find the drawable resource by the resId. what's your opinion?
In my app, this kind of bug happens only during upgrading. If the resource id changes in the newer version, Android RemoteView may fail to find the resource and throw out the RemoteServiceException. If you publish a 3rd version and do not change the resource id, the bugs may disappear only temporarily.
What was happening was, I was including the integer reference to the icon in the PendingIntent bundle, and that integer was later being referenced while being posted to the NotificationManager. In between getting the integer reference and the pending intent going off, the app was updated and all of the drawable references changed.
Using VectorXml inside your notification has been known to cause this issue. Use png's Only PNGs were being used. In my case, I had vector in drawable folder and png's in drawable-hdpi, xhdpi, etc. But there was no png for drawable-mdpi, and it crashed on MDPI device on posting a notification. Don't use SVG on Kitkat!
I was facing the same problem. I noticed I was using Vector Drawable for small icon and this error occurred only on pre-lollipop devices. Using PNG resource for pre-lollipop devices fixed the issue.
When using Firebases ability to set notification, use a PNG instead of a vector by setting default_notification_icon
in AndroidManifest.xml
We had the problem when receiving push notifications on a LG G2 with Android 4.4.2 Fabric (and catlog) showed the following stack trace:
Fatal Exception: android.app.RemoteServiceException: Bad notification posted from package de.xxx.xxx: Couldn't create icon: StatusBarIcon(pkg=de.xxx.xxx=0 id=0x7f0200a6 level=0 visible=true num=0 )
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1367)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5105)
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:792)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
at dalvik.system.NativeStart.main(NativeStart.java)
Notice, there is no class in stack trace matching our package. Also, onMessageReceived
was called (checked not only with debug break point but also Log.e(TAG, "...")
).
This means, that it's not us setting the notification, it is Firebase SDK.
Since there is no code involved, I figured (after painful hours of head banging) error must be in AndroidManifest.xml. We are setting another notification icon with the following snippet:
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/ic_notification" />
Here, @drawable/ic_notification
was a vector drawable (SVG). I changed it to a PNG and the crash was gone.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With