简体   繁体   中英

R.java not updating

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"
    ... />
  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

Jest clean the project and rebuild it still if you get the same problem delete the R.java from the eclipse it will recreated automatically with the new values.

Note: check R.java package imported in your project. If it's android.R jest replace with your package name.R;

When you make a Project/Clean it will not run properly if you have a resource with an error in its name, like for example an image with an upper case letter. Loot at the console error messages after the Clean.

remove unwanted files from project and remove unwanted code from menifest file . R.java will update automatically :)

I had the same problem. The only thing that finally solved it was deleting the id text that had been autogenerated by using the graphical layout. As soon as I manually typed the "@+id/... the .java file recognised it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM