Bad notification posted


Sometimes my application get this kind of exception:

Fatal Exception: Bad notification posted from package com.packagename: Couldn't expand RemoteViews for: StatusBarNotification(pkg=com.packagename user=UserHandle{0} id=136094146 tag=null score=0: Notification(pri=0 contentView=com.packagename/0x109007e vibrate=default sound=default defaults=0xffffffff flags=0x11 kind=[null]))
   at android.os.Handler.dispatchMessage(
   at android.os.Looper.loop(
   at java.lang.reflect.Method.invokeNative(
   at java.lang.reflect.Method.invoke(
   at dalvik.system.NativeStart.main(

Code creating notification:

PendingIntent intent = PendingIntent.getActivities(this, id,
        notificationIntents, PendingIntent.FLAG_UPDATE_CURRENT);

int color = ContextCompat.getColor(this, R.color.notif_background);

NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
        .setStyle(new NotificationCompat.BigPictureStyle().bigLargeIcon(largeIcon))

if (title != null) {
            .setStyle(new NotificationCompat.BigTextStyle()
} else {
    notificationBuilder.setStyle(new NotificationCompat.BigTextStyle()

if (image != null) {
            .setStyle(new NotificationCompat.BigPictureStyle()
} notification =;
notificationManager.notify(id, notification);

I have seen almost all the solution on stack overflow and it shows that this issue is regarding custom layout. But I didn't use custom layout. I couldn't understand what is the exact issue. Can anyone help?

asked on Stack Overflow Oct 26, 2016 by vidha

6 Answers


I had the same issuee when I used notification icons in .webp Be sure that you use icons in .png for devices with KitKat and below.

answered on Stack Overflow Jul 4, 2017 by jczerski

Try to change

int color = ContextCompat.getColor(this, R.color.notif_background);

Reading this answer:

Or change the order of setting the icons, reading this:

Could be the problem, I hope it helps you

answered on Stack Overflow Dec 19, 2016 by Pablo Cegarra • edited May 23, 2017 by Community

You have collision with styles - title sometimes might be null, so NotificationCompat.BigTextStyle() will be applied with bigText set and after that if image is not null NotificationCompat.BigPictureStyle() will be applied. Problem is, that bigText will be set, but style won't be relevant.

answered on Stack Overflow Dec 23, 2016 by Bio-Matic

This also happens between app updates. quite similar to this problem.

A possible explanation from this answer:

In between getting the integer reference and the pending intent going off, the app was updated and all of the drawable references changed. The integer that used to reference the correct drawable now referenced either the incorrect drawable or none at all (none at all - causing this crash)

answered on Stack Overflow Jun 8, 2018 by Rahul Tiwari

This crash happen when you use Vector in .setSmallIcon(R.drawable.ic_notification). I was using vector image with gradient items. I removed the gradient part. It started working fine on 5.0(lollipop), 6.0(marshmallow) notifications

answered on Stack Overflow Oct 2, 2019 by Nauman Ash

For me this work:

RemoteViews remoteViews = new RemoteViews(getApplicationContext().getPackageName(), R.layout.toolbar_custom_layout);

NotificationCompat.Builder builder = (NotificationCompat.Builder) new NotificationCompat.Builder(this)
                        .setContentTitle("example example")
                        .setStyle(new NotificationCompat.DecoratedCustomViewStyle())
                        .setContentInfo("content example");

NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

Also set RelativeLayout as your main parent in notification layout. In my case I had ConstraintLayout as parent and when I change it to RelativeLayout everythig start to work. I hope it'll help.

answered on Stack Overflow Apr 23, 2017 by stellyrepsolka

User contributions licensed under CC BY-SA 3.0