1

My PC went to sleep while battery was low. But when it recovered I found R.java file missing from my gen folder. My entire application is under crash. The error is shown below:

enter image description here

7
  • did you try clean and then build? Commented Jun 27, 2012 at 17:08
  • clean and rebuild you project Commented Jun 27, 2012 at 17:08
  • yea cleaned. Still missing. :( Commented Jun 27, 2012 at 17:09
  • and after doing this you still unable to find R.java then delete gen folder and then retry with clean & rebuild Commented Jun 27, 2012 at 17:09
  • 1
    Restart Eclipse, it will work fine. Sometimes You have to create new project when you copy paste from other project Commented Jun 27, 2012 at 17:12

4 Answers 4

1

If you recently added a new resource file and happen to use upper case letters in the file name, change the file name to lowercases and rebuild your project. That is what happened to my project.

The R.java file should be regenerated every time you do a rebuild of your project.

Sign up to request clarification or add additional context in comments.

Comments

1

Clean the project, Go through your code and remove all references to android.R.*

So when your R.java is corrupt or missing Eclipse tries to be helpful and thinks that the references in your code for R.something are missing the import file and inserts the android.R.* to your import list.

If you are using IntelliJ it has a rebuild R.java command.

If it is still missing then it means that something in your code is preventing it from being built. Pay attention to resource file names etc. Usually you can sport these naming problems in console view of eclipse

Comments

1

There are possible chances, you have a problem in your layout xml or in your code.

Try looking at file that you had open in your eclipse when it went to sleep, and code snippet that you were working at.

Edit:

R (resource file) regenrates at every rebuild of your project. For some error in your project your project wasn't able to build that why your R file is missing. All that you need to do is to fix issue in your files, code and xml files.

4 Comments

yeah, i jst now noticed my view.xml file is not opening. It is showing"The project target is not set". Could u explaing me ur point a bit more..
project target not set means, api level of android you are targeting is not set, Check following link for resolution: stackoverflow.com/questions/2292416/…
I am nt able to acess propeties. It is showing ivalid contents error window :(
are you able to open properties for some other project in your eclipse
1

I got the same issue. Nearly I spent whole day working on it to figure out the reason and tried all the 100 solutions provided in the blogs. But nothing helped!!! After setting up a new workspace I figured out. Remove unnecessary libraries in your project. You can check this by Project-> right click-> properties-> Android-> and remove unnecessary added libraries. It worked :) Hope it helps some one.

1 Comment

This question was some years back. It simple,,If there is any error in resource folder, such error occurs. Just clean the project and u will find the error generating resource . Any ways , upvote for sharing your views :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.