One android user had a crash on Nexus 5X device with this report:
Fatal Exception: java.lang.RuntimeException
Unable to start activity ComponentInfo{package.MainActivity}: android.view.InflateException: Binary XML file line #8: Binary XML file line #8: Error inflating class ImageView
android.app.ActivityThread.performLaunchActivity
Caused by android.view.InflateException
Binary XML file line #8: Binary XML file line #8: Error inflating class ImageView
Caused by android.view.InflateException
Binary XML file line #8: Error inflating class ImageView
Caused by android.content.res.Resources$NotFoundException
Drawable (missing name) with resource ID #0x7f0700b8
Caused by android.content.res.Resources$NotFoundException
Unable to find resource ID #0x7f0700b8
pointing to line 61 in Mainactivity: MainActivity.onCreate (MainActivity.java:61), which is this line:
this.setContentView(R.layout.activity_main);
I've found out that resource ID #0x7f0700b8 points to my image logo.png, which is present in all drawable folders (drawable,hdpi,ldpi,mdpi,xhdpi,xxhdpi,xxxhdpi) so I don't understand why the drawable is not found or what is the problem.
The imageview in XML looks like this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bgmain">
<ImageView
android:id="@+id/logo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="24dp"
android:contentDescription="@string/hrady_a_zamky"
android:paddingLeft="32dp"
android:paddingRight="32dp"
android:paddingTop="0dp"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
android:src="@drawable/logo" />
and Mainactivity:
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Locale locale = new Locale(lng);
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
this.getResources().updateConfiguration(config, this.getResources().getDisplayMetrics());
this.setContentView(R.layout.activity_main);
ImageView language = findViewById(R.id.lang);
ImageView logo = findViewById(R.id.logo);
ImageView award = findViewById(R.id.award);
if (lng.equals("sk")) {
language.setImageResource(R.drawable.en);
logo.setImageResource(R.drawable.logo);
}
else { language.setImageResource(R.drawable.sk);
logo.setImageResource(R.drawable.logoen);
}
}