Android Error - Error inflating class

android, java

Solution

This type of error can be fixed by going to the file `R.java` and search for the error entry e.g `0x7f0201f2` from your log. It would correspond to a variable. And if you look at the containing method of this entry it will tell you whether it is a string, id, dimen etc. Then you can just search for this variable in your project and find if it has been declared in your resource files.

Problem

I am just starting with android development through Java (i have only previously used phonegap). I created my first hello world project with a simple form text field and send button, and it won't run. My error log is below: ``` 12-06 20:31:11.482: E/AndroidRuntime(32656): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.thesurvivor2299/com.example.thesurvivor2299.MainActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class android.widget.RelativeLayout 12-06 20:31:11.482: E/AndroidRuntime(32656): Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class android.widget.RelativeLayout 12-06 22:32:31.304: W/ResourceType(804): Failure getting entry for 0x7f0201f2 (t=1 e=498) in package 0 (error -2147483647) 12-06 22:32:31.305: W/ResourceType(804): Failure getting entry for 0x7f0201f3 (t=1 e=499) in package 0 (error -2147483647) 12-06 22:32:31.305: W/ResourceType(804): Failure getting entry for 0x7f0201f4 (t=1 e=500) in package 0 (error -2147483647) 12-06 22:32:31.580: W/ResourceType(804): Failure getting entry for 0x7f020609 (t=1 e=1545) in package 0 (error -2147483647) 12-06 22:32:31.581: W/ResourceType(804): Failure getting entry for 0x7f020627 (t=1 e=1575) in package 0 (error -2147483647) 12-06 22:32:31.624: W/ResourceType(804): Failure getting entry for 0x7f0201f2 (t=1 e=498) in package 0 (error -2147483647) 12-06 22:32:31.624: W/ResourceType(804): Failure getting entry for 0x7f0201f3 (t=1 e=499) in package 0 (error -2147483647) 12-06 22:32:31.624: W/ResourceType(804): Failure getting entry for 0x7f0201f4 (t=1 e=500) in package 0 (error -2147483647) 12-06 22:32:31.646: W/ResourceType(804): Failure getting entry for 0x7f020609 (t=1 e=1545) in package 0 (error -2147483647) 12-06 22:32:31.646: W/ResourceType(804): Failure getting entry for 0x7f020627 (t=1 e=1575) in package 0 (error -2147483647) ``` As there are a lot of files, i'm not sure which would be best to provide the code of. Let me know which file, and i'll copy the code in here. MainActivity.java: ``` public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } } ``` activity_main.xml: ``` <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@style/AppTheme" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity" > <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/hello_world" /> <EditText android:id="@+id/editText1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft="@+id/textView1" android:layout_below="@+id/textView1" android:layout_marginTop="35dp" android:ems="10" android:inputType="textWebEditText" android:singleLine="true" /> <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignRight="@+id/textView1" android:layout_below="@+id/editText1" android:layout_marginTop="36dp" android:text="Send" /> </RelativeLayout> ``` I can post any of the code if it helps

Original source