• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps R cannot be resolved to a variable

Just after creating the new Android Application Project, I get the error "R cannot be resolved to a variable" in my MainActivity.java file

Why am I getting this problem if the app was created by Eclipse choosing all the default options? How can I fix this issue?

one more thing
I am new to Android, pls help me on this, Thanks in Advance.
 
Try doing Project > Clean first to see if it fixes the issue.

However, I tend to get this problem when one of the xml files has an error. There may be an error in the xml file even though Eclipse isn't pointing it out for you...
 
Hi Mills thanks for ur reply I did as you said. still i am getting the error. this is my xml file.


<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: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:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />


</RelativeLayout>
 
Back
Top Bottom