R.java not updating

philipfoster picture philipfoster · Jun 29, 2012 · Viewed 8.1k times · Source

I am unable to build my app because R.java will not update the ids. I updated the id in main.xml but the old values remain. This obviously prevents it from building. Is there any way to fix this? Could I manually update R.java by renaming the variables and leaving the references untouched, or is this unsafe? There are no problems other than the 3 lines of code posted below and unused variable warnings.

StopwatchAppActivity.java:

pauseBtn = (Button)   findViewById(R.id.pause_btn);
resetBtn = (Button)   findViewById(R.id.reset_btn);
timeDisp = (TextView) findViewById(R.id.time_tv);

main.xml:

<TextView
    android:id="@+id/time_tv"
    ... />

<Button
    android:id="@+id/pause_btn"
    ... />

<Button
    android:id="@+id/reset_btn"
    ... />

Answer

Jack Satriano picture Jack Satriano · Jun 29, 2012
  1. Check all of your XML,
  2. Project -> Clean,
  3. Right click -> Fix Project Properties,
  4. Repeat.
  5. Maybe try restarting Eclipse

My panic list for R generation problems