“Failed to convert ?attr/colorPrimary into a drawable”

谁说我不能喝 提交于 2019-12-05 11:30:17
Abhishek

There is a bug in android [pre-lollipop] OS which doesnt allow you to use attr in drawable. Here is the link to bug:

https://code.google.com/p/android/issues/detail?id=26251

Android dev team has released a fix but it works on android L and above. For workaround to this problem, refer to following solution:

How to reference style attributes from a drawable?

ZA BroadPeak

Prepend android keyword to it.

?attr/colorPrimary"

becomes

?android:attr/colorPrimary

working fine in android studio 3.0 .

There is problem on below Android OS version -21 .You can use

android:background="?attr/colorPrimary"

instead of

app:background="?attr/colorPrimary"

It will work fine.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!