Fatal Exception: android.app.RemoteServiceException Bad notification posted from package:* Couldn't create icon: StatusBarIcon
See original GitHub issueMy app is crashing when showing a local notification on Samsung devices using Android 8.1.
I tested using an emulator on Android 8.1 and everything is fine, I’m guessing this is a problem with Samsung, anybody knows what can be done to solve this problem?
Your Environment
- Plugin version: 0.9.0-beta.2
- Platform: Android
- OS version: 8.1
- Device manufacturer / model: Samsung Galaxy J7 Prime
- Cordova version (
cordova -v
): 9.0.1 - Cordova platform version (
cordova platform ls
): 8.1.0 - Plugin config: “cordova-plugin-local-notification”: {}
- Ionic Version (if using Ionic): @ionic-native/core: 5.18.1-beta.5
Expected Behavior
Show a notification
Actual Behavior
App crashes
Steps to Reproduce
Send a local notification, app crashes immediately
Context
Send a local notification
Debug logs
Include iOS / Android logs
This is what showed in Firebase Crashlytics stacktrace:
Fatal Exception: android.app.RemoteServiceException
Bad notification posted from package: ** Couldn't create icon: StatusBarIcon(icon=Icon(typ=RESOURCE pkg=** id=0x01020006) visible user=0 )
android.app.ActivityThread$H.handleMessage (ActivityThread.java:1906)
android.os.Handler.dispatchMessage (Handler.java:106)
android.os.Looper.loop (Looper.java:164)
android.app.ActivityThread.main (ActivityThread.java:7000)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:441)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1408)
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:8
Top Results From Across the Web
android.app.RemoteServiceException: Bad notification posted ...
How to fix: android.app.RemoteServiceException: Bad notification posted from package *: Couldn't create icon: StatusBarIcon · Ask Question.
Read more >Bad notification posted from package : Couldn't create icon
Exception : android.app.RemoteServiceException: Bad notification posted from package : Couldn't create icon: StatusBarIcon.
Read more >RemoteServiceException is thrown when posting notification ...
android.app.RemoteServiceException: Bad notification posted from package com.example: Couldn't create icon: StatusBarIcon(pkg=com.example user=0 ...
Read more >Bad notification crash - Google Groups
Bad notification posted from package com.gmail.pbilton.footballscoreswatchmaker: Couldn't create icon: StatusBarIcon(icon=Icon(typ=RESOURCE ...
Read more >android.app.RemoteServiceException: Bad notification posted ...
Android – How to fix: android.app.RemoteServiceException: Bad notification posted from package *: Couldn't create icon: StatusBarIcon.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@GitFr33 It was:
res://mipmap-xxxhdpi/ic_stat_zin.png
Where ic_stat_zin.png was a icon that has transparency and is pure white. The name of the file may differ. If you do not make an icon that is pure white it will not work, as there are configurations in android to color the icon in xml. Or in the case of localnotification this is done through a function call if I’m not mistaken.
This is also the reason why the notification icon generator in android asset studio only generates white icons. https://romannurik.github.io/AndroidAssetStudio/icons-notification.html#source.type=clipart&source.clipart=ac_unit&source.space.trim=1&source.space.pad=0&name=ic_stat_ac_unit (I hope this doesn’t sound racist, it’s just how google made it work for notifications)
The location of where to put this icon is in:
/android/app/src/main/res/mipmap-xxxhdpi/
this can be any of the mipmap directories, I went for the biggest one because it would guarantee quality on all screens. I thinkres://
points to/android/app/src/main/res/
but I haven’t tested whether it’ll work with custom directories yet.Since there was no documentation I kind of figured this out on my own through some logical reasoning. I basically looked at how native apps do it. And also the word res (which I assume is resource) gave it away.
What I did to fix the issue was set a correct smallIcon in the local notification properties. Apparently the default icon for the local notification causes issues.
EDIT: Presumably because it is not white?