Android 异常 “Binary XML file line # : Error inflating class”

使用了CommonTitleBar自定义标题栏,但是出现错误如下:
...
android.view.InflateException: Binary XML file line #11: Error inflating class com.wuhenzhizao.titlebar.widget.CommonTitleBar
...
android.view.InflateException: Binary XML file line #31: Error inflating class TextView
...
android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f070079 a=-1 r=0x7f070079}
...

在渲染layout或者Inflater.inflater()解析布局时出现了运行时异常“ Binary XML file line # : Error inflating class”,定位到xml文件中发现该行是TextView,它的backgroud引用了drawable下资源,但是资源只存在drawable-v21目录,但是drawable目录没有。将对应资源文件copy到values目录下就解决了问题。

参考:
https://blog.csdn.net/samuel__liu/article/details/53761683
http://stackoverflow.com/questions/3739661/error-inflating-when-extending-a-class

你可能感兴趣的:(Android 异常 “Binary XML file line # : Error inflating class”)