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 \'
For me, inside one of my layout.xml files, I had
<ImageView
android:id="@+id/row_1_col_0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@string/default_picture_location">
</ImageView>
and inside strings.xml, I had
<string name="default_picture_location">"@mipmap/tile"</string>
and so it was showing this in Android Studio:
<ImageView
android:id="@+id/row_1_col_0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@mipmap/tile">
</ImageView>
I thought everything would work because there were no errors and the application compiled and ran. However, there was a run time error that said "android.view.InflateException: Binary XML file line #7:Error inflating class ImageView".
Once I changed android:background from
android:background="@string/default_picture_location"
to
android:background="@mipmap/tile"
everything worked.
For me it works when I paste image in both drawable
and drawable-v24
and I added some code android:src="@drawable/battman"
try to change
v = View.inflate(getContext(), R.layout.event_show_row_layout, null);
to
v = View.inflate(getApplicationContext(), R.layout.event_show_row_layout, null);
Putting image in drawable NOT as "v-24" worked for me and I stopped get the crash.
you haven't closed LinearLayout tag
and please use following code for inflating layout.xml
LayoutInflater inflater = getLayoutInflater();
final View v = inflater.inflate(R.layout.your_layout_id, null);
I have the resources in the drawable-zh-xxhdpi
catalog documents, but not in the drawable-xxhdpi
catalog of resources, the emergence of this mistake.
This should be:
res
drawable-xxhdpi
aa.png
drawable-zh-xxhdpi
aa.png