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

前端 未结 14 2031
忘掉有多难
忘掉有多难 2020-12-03 06:56

I know there are other questions on SO asking the same thing. I have already looked at most of them.

Most answers call about memory errors. I can\'t see how an

相关标签:
14条回答
  • 2020-12-03 07:28

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

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

    0 讨论(0)
  • 2020-12-03 07:30

    This issue is usually caused when you copy drawables files to drawable-24 folder instead of drawable folder. So, copy all images from drawable-24 folder to drawable.

    0 讨论(0)
  • 2020-12-03 07:31
    android:src="@raw/ic_image"
    

    I added the image file to new directory called raw and it solved my problem.

    0 讨论(0)
  • 2020-12-03 07:32

    I also use to face this error most often. The reason behind why this error comes is,

    1) In ImageView we have used wrong format of image, or an image when we designed and saved it didn't get save properly. it's extension got broken somehow.
    2) One another reason of this error is we have used an xml with drawable. For example, android:src="@drawable/ic_left", here ic_left is an xml file in drawable that we are using.

    So, to avoid this kind of error, always use .png format image with ImageView. In my case the error was,

    java.lang.RuntimeException: Unable to start activity ComponentInfo{package name of project/ActivtyName}: android.view.InflateException: Binary XML file line #255: Binary XML file line #255: Error inflating class ImageView

    0 讨论(0)
  • 2020-12-03 07:34

    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...".

    0 讨论(0)
  • 2020-12-03 07:35

    What helped me is just copying the image file (.png in my case)

    • from res\drawable-v24

    • to \res\drawable directory.

    Will happy if this post will save time to somebody else.

    0 讨论(0)
提交回复
热议问题