R.java disappears after project clean

Viewed 47392

After I added some .png files into my Project Workspace drawable folder I refreshed my drawable folders in Eclipse and the newly added files showed up. But when I tried to access those resources using R.drawable.xyzimage, xyzimage although in the folder could not be resolved.

So I did a Project Clean and guess what after this clean R.java is totally gone and all my classes accessing resources using R.java is showing all sorts of error and Eclipse won't let me run the code anymore.

I have backup of my source code but I want to explore if R.java can be regenerated and how?

Thanks for all the help.

34 Answers

I had an invalid jpg in my res/drawable folder. I removed the jpg and it worked.

I had the dreaded missing R problem yesterday with Eclipse Juno after a routine clean. StackExchange is full of suggestions and extensive googling revealed only the usual suspects (XML naming conventions problems, etc) none of which seemed to apply directly, although it is certainly possible I missed something.

The best summary comprehensive list of possible causes and fixes was here:

http://www.techrepublic.com/blog/software-engineer/a-comprehensive-troubleshooting-guide-for-androids-r-cannot-be-resolved-error/

One useful tip there was to try to create and run a simple "Hello World" in my workspace. If that does not run, the setup is corrupted. My Hello World was just as full of errors as my custom app.

The solution that worked for me (perhaps great overkill but nothing else worked) was to completely uninstall Android SDK and delete Eclipse (Juno), download Eclipse for Developers (Kepler) and reinstall Android ADT plugin and ADK and recreated my AVDs using the latest "compile with" version in options.

So far so good, although I am recreating the app from scratch. I will be more cautious about using clean from here on.

Related