While working in Android Studio, I accidentally clicked the button "Sync Project with Gradle Files" in the toolbar. Now all instances of R are highlighted in red as "Cannot resolve symbol R". Additionally, all folders but the app name in the directory structure toolbar are red-underlined, and I have a message saying that the IDs for three checked radio buttons in one of my XML layout files can't be found (even though they're a few lines below). There's not even an R.java anywhere in the project structure. Restarting Android Studio did not fix this; neither did pressing the same button again.
Edit: I'd hoped to be able to copy all my files to a new project, but the problem persists in new projects, too.
Here is my XML file; I have removed the checked-by-default buttons:
<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"
android:screenOrientation="landscape"
tools:context="com.cmpt276.darren.minions.OptionsMenu">
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:id="@+id/linearLayout2">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/num_rows"
android:id="@+id/textView8"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true" />
<RadioGroup android:layout_width="wrap_content"
android:layout_height="wrap_content">
<!--//android:checkedButton="@id/rows3"-->
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/rows3"
android:id="@+id/rows3" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/rows4"
android:id="@+id/rows4" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/rows8"
android:id="@+id/rows8" />
</RadioGroup>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/num_minions"
android:id="@+id/textView9" />
<RadioGroup android:layout_width="wrap_content"
android:layout_height="wrap_content">
<!--android:checkedButton="@id/numMinions6"-->
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/minions_6"
android:id="@+id/numMinions6" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/minions_10"
android:id="@+id/numMinions10" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/minions_15"
android:id="@+id/numMinions15" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/minions_20"
android:id="@+id/numMinions20" />
</RadioGroup>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/num_columns"
android:id="@+id/textView10"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<RadioGroup android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/num_columns">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/columns4"
android:id="@+id/columns4" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/columns6"
android:id="@+id/columns8" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/columns12"
android:id="@+id/columns12" />
</RadioGroup>
</LinearLayout>
</RelativeLayout>