Android.view.inflateexception Binary Xml File Line #1 Error Inflating Class Android.widget.relativelayout
Solution 1:
You have to change
android:background="@layout/activity_main"
to
android:background="@drawable/yourImageName"
Solution 2:
Sometimes this error can also pop up when you are using a large image that is actually too big that leads to a memory error and crashes your app. If you are using background images or any large assets make sure they exist and that they aren't too big and then you'll be singing in the rain!
Solution 3:
this line is indicating the first line of the layout:
android.view.InflateException: Binary XML file line #1: Error inflating class
and at the first line there is Relative layout declaration:
So The error is on android:background
, and This is not the correct way to set background of layout:
android:background="@layout/activity_main"
it should be a color or drawable image
android:background="@color/backgroundColor"
or android:background="#012345"
or
android:background="@drawable/backgroundimg"
Solution 4:
This is wrong android:background="@layout/activity_main"
should be
android:background="@color/backgroundColor"
or
android:background="@drawable/backgroundimg"
Solution 5:
What fixed it in my case was to change the location of my color.xml
As I copied it from some other project of mine and pasted it in the new project, Android Studio placed it in the v21
folder, meaning my emulator (v19) could not reach the resource file color.xml
.
I did the following to fix it:
- Right click on
color.xml
. - Select
Refactor
>Move
. - On the dialog that open, removed the suffix
-v21
.
Now, my "old" emulator was able to read the file.
I hope it helps..
Post a Comment for "Android.view.inflateexception Binary Xml File Line #1 Error Inflating Class Android.widget.relativelayout"