Error inflating class ImageView

前端 未结 17 2217
失恋的感觉
失恋的感觉 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:39

    In my case the svg had letters that have gaps and then this caused the bug, what I did was modify the letters in illustrator removing the gaps and it worked.

    0 讨论(0)
  • 2020-12-29 21:40

    I myself had this problem because my image was in darawable-v24 directory. so when I wanted to use older api, the app was crashing. so I suggest to check whether you're resource is in correct directory or not.

    0 讨论(0)
  • 2020-12-29 21:41

    In my case I had the same error, but only when using a device with API < 24 (emulator or physical device).

    This was caused by the use of "gradient" inside a SVG I imported.

    The error do not appear in the stacktrace, but it appears in the .xml of the imported SVG file:

    This causes the app to crash when inflating a View that has this SVG as its source, for APIs < 24.

    If you want to use SVG only, you can restrict the use of this resource to APIs >= 24 and remove the gradient for APIs below.

    0 讨论(0)
  • 2020-12-29 21:42

    I came across this same problem recently and was able to solve it using app:srcCompat="@drawable/ic_black_image_24"

    The documentation of appcompat:srcCompatstates that -

    It sets a drawable as the content of this ImageView. Allows the use of vector drawable when running on older versions of the platform.

    Hope this helps if anyone stumbles upon the same problem.

    0 讨论(0)
  • 2020-12-29 21:45

    I had the same problem. my problem has occurred because I just had used images (icons) in the "drawable-v24" folder. I solved it by copying them into "drawable" folder

    0 讨论(0)
  • 2020-12-29 21:45

    I had the same issue, because I copied my png files to drawables while on Android view, and it automatically copied to drawable-v24, but you need to copy your files to drawable, you can navigate to your project and then res/drawables and paste it manually, or change your view to project view the past it in the drawable folder

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