Posts

Showing posts from August, 2018

Android - UnsupportedOperationException: Cant convert to color: type=0x2

 You are most likely trying to reference a styleable attribute of reference type in a drawable resource and it bailed out with an UnsupportedOperationException.    <shape android:shape="rectangle">         <solid android:color="?attr/item_background" />     </shape> Sadly this is the case with pre-lollipop android versions. There isn't any way to reference attributes in a drawable resource. This works just fine in Lollipop though and is tracked here . The only other alternative is to have a hard coded color specific drawable resource for older platform versions. /drawable/red_rectangle.xml    <shape android:shape="rectangle">         <solid android:color="@android:color/red" />     </shape> /drawable/orange_rectangle.xml    <shape android:shape="rectangle">         <solid android:color="@android:color/orang...