InflateException: Binary XML file line #8: Error inflating class ImageView

白昼怎懂夜的黑 提交于 2019-11-27 05:01:40

The stack trace doesn't show it, but the error during inflation might come from drawable used in the ImageView, in this case:

android:src="@drawable/ic_dot"

OP tested this hunch, by trying a different drawable which "seems ok right now...".

binary xml file line #0: error inflating class imageview

you have to see if your image has become drawable-v23 or v24 which might be higher than your mobile os level, Make sure to avoid creating drawable version image in project

example In drawable folder ~> "ic_contact(v24)"

If you are using vector drawables, use

app:srcCompat="@drawable/ic_dot"

instead of

android:src="@drawable/ic_dot"

I had the same problem. The png image for my imageView was causing a class inflateException. This was only happening with my phone running android 6.0.1, but not in my phone running android 7.0. To solve this:

---In Android Studio---

  • Deleted the png image from the drawable folder (I only have the drawable folder visible, not the drawable-v24).
  • Copy the png back to the drawable folder. When doing this, you'll be able to pick to copy it to either the drawable or drawable-v24 folder. Copy the png to both folders
  • Copy the png to both folders (png's must have same name).
  • Once you copy the png to both folders, a new folder with the png's name will show up. Inside it you will see the 2 png's. One with "(v24)" next to it. New folder with name of png's will appear, containing png's

In my case I had app:srcCompat="@drawable/ic_svg_image" inside ImageView, but it was very complex SVG. Though it showed in Design tab, an application crashed.

I changed it to PNG.

Don't paste your image into drawable in Android studio, paste it into the drawable folder and clean the project and then run it will work.

I also face this kind of problem . the simplest way to solve

Just Put your drawable files in drawable directory, not drawable 24.

Nitin Karale

The following code might be added in Android Manifests-Activity

<activity
android:name=""
--------------
android:theme="@android:style/Theme.Black.NoTitleBar">
</activity>

please remove this theme if you have added.

My problem has been solved after removing this theme. I got these solution after long time.

using android.support.v7.widget.AppCompatImageView without android:background solved the problem for me.

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