This happened yesterday when i was replacing a few elements in my XML. When I went to my main class, I saw that all references to R had been marked red, and I was told that R could not be resolved to a variable. At first, I tried to rebuild and clean up my project, but that didn't work, so I am assuming that the issue lies in the XML file I recently edited, however I do now know where the issue would lie. And yes, I did make sure android.R was not being imported.
A few additional details:
- I am using Android 5.0 (API 21)
- The R issues do not appear in my other class files, which reference R.
Here is the XML file in question:
<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:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MainActivity">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView2"
android:layout_marginTop="20dp"
android:text="@string/rye"
android:textColor="#888888"
android:textAppearance="?android:textAppearanceLarge" />
<RatingBar
android:id="@+id/ratingBar1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_below="@+id/textView1"
android:isIndicator="false"
android:numStars="5"
android:stepSize="1" />
<Button
android:id="@+id/dropDownButton"
android:layout_width="48dip"
android:layout_height="48dip"
android:layout_alignBottom="@+id/ratingBar1"
android:layout_toRightOf="@+id/ratingBar1"
android:onClick="dropDown"
android:text=">"/>
<RelativeLayout
android:id="@+id/dropDownLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignTop="@+id/textView2"
android:visibility="gone" >
<TextView
android:id="@+id/testTV"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Testing dropdown" />
</RelativeLayout>
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/tipTitle"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#888888"
android:layout_below="@+id/quizFragment"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<FrameLayout
android:id="@+id/quizFragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/dropDownButton" />
<TextView
android:id="@+id/TextView02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/people_dining_title"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#888888"
android:layout_below="@+id/seekBar3"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:id="@+id/subtotalTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/subtotal"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#888888"
android:layout_below="@+id/seekBar2"
android:layout_alignLeft="@+id/seekBar2"
android:layout_alignStart="@+id/seekBar2" />
<TextView
android:id="@+id/totalTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/subtotalText"
android:layout_below="@+id/subtotalText"
android:layout_marginTop="10dp"
android:text="@string/total"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#888888" />
<TextView
android:id="@+id/totalText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/subtotalText"
android:layout_alignRight="@+id/subtotalText"
android:layout_below="@+id/totalTitle"
android:focusable="false"
android:padding="2dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#ffff000c" />
<EditText
android:id="@+id/subtotalText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/subtotalTitle"
android:ems="10"
android:hint="SUBTOTAL"
android:inputType="numberDecimal"
android:padding="2dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#ff0000"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignRight="@+id/seekBar2"
android:layout_alignEnd="@+id/seekBar2">
</EditText>
<TextView
android:id="@+id/eppTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/totalText"
android:layout_below="@+id/totalText"
android:layout_marginTop="10dp"
android:text="@string/epp"
android:textColor="#888888"
android:textAppearance="?android:textAppearanceMedium" />
<TextView
android:id="@+id/eppText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/eppTitle"
android:layout_alignRight="@+id/totalText"
android:layout_below="@+id/eppTitle"
android:focusable="false"
android:padding="2dp"
android:text=""
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#FFFFFF" />
<Button
android:id="@+id/buttonDone"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/eppText"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:onClick="done"
android:text="@string/done"
android:textStyle="bold" />
<SeekBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/seekBar2"
android:layout_below="@+id/TextView02"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<SeekBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/seekBar3"
android:layout_below="@+id/textView2"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"/>
</RelativeLayout>