I am receiving many errors of kind displayed in the subj. These errors seems to be occasional and I cannot reproduce them. From stack I can learn that such error may occurs
The inflate exception is not actually the problem, but really comes from another deeper issue in your layout that is then wrapped in an InflateException. A common issue is an out of memory exception when trying to inflate an imageview loading a drawable resource. If one of this resources has a high pixel resolution it would take a lot of memory causing then an inflate exception.
So basically verify that the pixel resolution in your drawables images are just the minimum necessary for your layout.
I had the same error when creating custom view with only one constructor, try to define all constructor for your custom views.
public CustomWebView(Context context) {
super(context);
init();
}
public CustomWebView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public CustomWebView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init();
}
This can also happen if you use a VectorDrawable
using support library and forgot to use app:srcCompat
instead of android:src
Exact error is: Binary XML file line #XX: Error inflating class ImageView
See that link
I encountered the same bug and found the root reason is:
Use Application Context to inflate view.
Inflating with Activity Context fixed the bug.
In case someone gets similar issues, I had such an issue while inflating the view:
View.inflate(getApplicationContext(), R.layout.my_layout, null)
fixed by replacing getApplicationContext()
with this
I had the same error on Kitkat which was because i had android:tint on one of the imageViews. It would work fine on Lollipop but crash on Kikkat with Error Inflating class .
Fixed it by using app:tint on the AppCompatImageView which i was dealing with.