简体   繁体   中英

Android Issue: Project r.java disappears when I clean/rebuild

Hi I'm having an issue with the r.java file. It sometimes doesn't reference my xml files such as styles/strings etc (No errors). However I heard project clean/rebuild helps, I did it and it has deleted my r.java file. I've tried refreshing but to no avail. Is there a way of getting it back? I've been working on it all day and I can't get my head around it. I've started new projects and this always happens.

Please help. Thanks.

The R.java file is built from your res xml files. Cleaning will cause it to be deleted and you'll have to wait for a build to get it back.

Ways to force a build in Eclipse include

  • opening any file, making any change, including adding a space then removing it, then saving the file
  • Trying to run the app on emulator/device (though eclipse sometimes recognises the lack of R.java as an error and stops the procedure)
  • uncheck and re-check Project Build Automatically to force a rebuild

There are other ways I'm sure but these are the easiest.

Building the project should do the trick...

(maybe you need to change something in the code before (just add a space))

Make sure there are no errors in your xml files. If this doesn't work try cleaning the project.

Do you have 'Build Automatically' checked under Project in Eclipse. When you do a clean R.java and any other file in the gen folder are supposed to be deleted and recreated when you build. If that still doesn't work then try removing the project from your workspace and re-add it. That often times fixes a lot of issues with projects in Eclipse for me.

It happened with my project too, just click on the project and ctl+z and you will get it back

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