In my app, we are showing one notification which do have 2 or 3 action button.
I'm getting crashes on crashlytics for some devices which incldes Blackberry, Asus, HTC< HUAWEI, Quanta, Oppo, Vivo, Samsung, Yu, MicroMaxx, OnePlus, Lenovo, iTel, Royal, etc so many devices
Please note that it is not crashing for every devices. I've tried on more than 6 devices and it is working fine but crashing on some devices, mostly Hisense manufacturer.
Crash reason:
Fatal Exception: android.app.RemoteServiceException: Bad notification posted from package net.AppName: Couldn't expand RemoteViews for: StatusBarNotification(pkg=net.AppName user=UserHandle{0} id=1536490752 tag=null score=0 key=0|net.AppName|1536490752|null|10115: Notification(pri=0 contentView=net.AppName/0x109007e vibrate=null sound=default defaults=0x1 flags=0x10 color=0x00000000 actions=3 vis=PRIVATE))
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1469)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5270)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:915)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:710)
Notification builder code I'm using is :
var mBuilder = NotificationCompat.Builder(context)
.setLargeIcon(BitmapFactory.decodeResource(context.resources, R.drawable.in_ic_icon_v4))
.setSmallIcon(R.drawable.in_ic_notification_icon_v4)
.setContentTitle(context.getString(R.string.msg_new_account))
.setContentText(body)
.setStyle(NotificationCompat.BigTextStyle().bigText(body))
.setDefaults(Notification.DEFAULT_SOUND)
.setAutoCancel(true)
mBuilder.addAction(-1, skip, getPendingIntent(getIntentForAction(context, skipBundle), context, requestCode))
mBuilder.addAction(-1, skip, getPendingIntent(getIntentForAction(context, skipBundle), context, requestCode))
val mNotificationManager = context.applicationContext.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
mNotificationManager.notify(id, mBuilder.build())
It is throwing RemoteServiceException. The irony is that I don't have any RemoteView in Notification. Can someone help me in this?
Is it something related to icon size? I'm using pngs and max size is 20kb(for xxhdpi). also I've read somewhere that .setStyle(NotificationCompat.BigTextStyle().bigText(body)) can cause the problem, is it so?