Bad notification posted - Couldn't expand RemoteViews for: StatusBarNotification

Solution 1:

For me, the problem was that I was setting a specific height for the root layout, in the custom notification view xml file.

As soon as I changed:

android:layout_height="@dimen/notification_expanded"

to

android:layout_height="match_parent"

in the root layout of notification view, the problem was solved.

Also take a look at this example to see a simple example of using custom layout for notifications.

Solution 2:

for unknown reason you are not allowed to reference dimention in the root view of the custom remote view! so you have to hard code it like android:layout_height="64dp" but if you used android:layout_height="@dimen/notification_height_that_64" it will give you Bad notification posted - Couldn't expand RemoteViews for: StatusBarNotification . i hope this will help :)

Solution 3:

In my case the exception was caused by a regular View in my custom notification layout. Basically, it's because you're allowed to use only certain widgets like TextView, ImageView and so on.

Solution 4:

In my case, i was able to fix this error by reducing the icon size i was providing into .setSmallIcon();