Error inflating class ImageView

前端 未结 17 2148
失恋的感觉
失恋的感觉 2020-12-29 21:01

I\'ve been getting InflateException/ClassNotFoundException error intermittently. I\'ve seen similar errors before in SO but they were caused by spelling errors. I spelled \'

相关标签:
17条回答
  • 2020-12-29 21:59

    The error during inflation might come from drawable used in the ImageView, in this case:

    android:background="@drawable/timeline_image_border"
    android:src="@drawable/timeline_image_dummy"
    

    To get rid of it, replace all the existing images trying a different drawable.

    0 讨论(0)
  • 2020-12-29 22:00

    Don't name XML file and image file the same name like this:

    0 讨论(0)
  • 2020-12-29 22:02

    It's an old question but I just came across the same problem. In my case it was caused by using the android:tint attribute with an selector rather than a color:

    <ImageView
        ...
        android:tint="@drawable/some_selector" />
    

    While this works without a problem a SDK 21+ it crashes in older versions...

    Switching to AppCompatImageView and to app:tint solved the problem:

    <android.support.v7.widget.AppCompatImageView
        ...
        app:tint="@drawable/some_selector" />
    
    0 讨论(0)
  • 2020-12-29 22:03

    For me , i copy my image to Folder drawable-v24 and compiler didnt find it

    Change view of Android studio to project view

    and cut and paste your image to folder drawable

    0 讨论(0)
  • 2020-12-29 22:03

    For me the problem was that the svg-file was to big.

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