I am new in android.
I just made a new layout with one text bar and 2 buttons but it didn\'t work, I am posting the stack trace and my relative layout file any idea about th
This is wrong android:background="@layout/activity_main"
should be
android:background="@color/backgroundColor"
or
android:background="@drawable/backgroundimg"
I had the same problem - but in a activity that had no background image.
I found out that the GUI editor (when using Eclipse - I don't know about Android Studio) sometimes adds the buggy property without any reason:
android:background="@layout/activity_main"
I'm not sure why the editor does so - maybe it is a bug or simply a usage error.
However if the activity does not have a background image the entire property simply has to be deleted!
If you use Google Play Services and show Maps you should add Meta tag in AndroidManifest.xml
**<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />**
You have to change
android:background="@layout/activity_main"
to
android:background="@drawable/yourImageName"
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"
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:
color.xml
.Refactor
> Move
.-v21
.Now, my "old" emulator was able to read the file.
I hope it helps..