Error inflating class ImageView

前端 未结 17 2397
失恋的感觉
失恋的感觉 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条回答
  •  旧时难觅i
    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.

提交回复
热议问题