I am trying to post a notification with a custom view in the notification area from an IntentService
, and getting the Couldn\'t expand RemoteView
e
Be careful when using Vector drawables. On pre-Lollipop devices setting an icon through NotificationCompat.Builder
methods, like setSmallIcon
, will cause this crash. You'll get same crash if using Vector drawables in your custom view.
I got the same error, but the problem for me was the constrain layout. I changed it to Relative Layout
to fix the the problem.
In my case, the problem was an inconsistency between the call
setShowActionsInCompactView(0)
And the .addAction
calls...The number of actions was different, hence the error
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.
I had the same problem. In my case:
reason -> I used for the builder.setAction(R.drawable.icon,...) function a vectordrawable and I tried also to enable them from support lib but nothing worked. In recent Android systems I do not see action icons, in the others it gives this error.
solution -> I did not find nothing, the only workaround for me is to avoid .xml files for drawables and to use the .png files in all directories hdpi mdpi ldpi..
I was facing same issue in showing custom layout in notification and what i found is:
I was using ConstraintsLayout as a root layout of my custom notification, this is the mistake i was committing. As there are some limitations with constrain layout to be used in android.
Finally i changed my root layout to RelativeLayout and my notification showing perfectly. I have attached my view in below screenshot.