android.view.InflateException: Binary XML file line #: Error inflating class

匆匆过客 提交于 2019-12-07 19:28:26

I think the Problem is in your Drawable Image. The error InflateException is common issue is an out of memory exception when trying to inflate an imageview loading a drawable resource. If one of this resources has a high pixel resolution it would take a lot of memory causing then an inflate exception.

So basically verify that the pixel resolution in your drawables images are just the minimum necessary for your layout.

I had this error message, When I was using a library called com.mikhaellopez:circularimageview and i had the image scale type set to Center_Inside

which was not supported by the library. After removing that line in the xml layout it worked fine.

@drawable/filebinder or @drawable/diarybookmark not a valid drawable.

Official doc: https://developer.android.com/guide/topics/resources/drawable-resource.html

Drawable could be png, jpg, gif files or drawable defined by a XML file as state drawable, shape drawable, ...

In my case the reason of this error was that I added the dimen resource to values-land/dimens.xml, but not in values/dimens.xml. Then IDE didn't show any warning/error but at runtime obviously the layout couldn't be drawn.

In general the best way is commenting/deletion views in the layout file one by one to realise which view causes an error.

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