Davlog
Davlog

Reputation: 2238

Eclipse deleted R File after clean

I tried to clean my project through Project->Clean and then suddenly all my R.java files in all my projects have been deleted. I don't know how to regenerate it now because I have hundreds of errors now...

How do I get my R.java files back?!

Upvotes: 0

Views: 69

Answers (3)

Val
Val

Reputation: 525

This happened to me yesterday, there are a few options you can try.

First try building the project again.

If that fails, try removing the gen file in eclipse and clean again

If that fails, try checking your xml files if there is any error

If everything fails, create a new project and copy-paste all layouts/src files to the new project.

EDIT: I searched for this yesterday, and I tried every possible solution, but only creating a new project helped.

Upvotes: 1

Aashir
Aashir

Reputation: 2621

R.java files are generated automatically by Eclipse. Check if you have Project > Build Automatically checked or not. If not, check it and it should resolve your issue. Alternatively, check your project for other errors, preventing the R.java files form being generated.

If the issue still persists, try restarting Eclipse.

Upvotes: 0

Giru Bhai
Giru Bhai

Reputation: 14398

Do follwing tasks:-

  • If there are any errors in the layout or any resource files there will be no build happening and the R.java file will not be created.
  • Please solve the errors and then try to clean the project.

    Or If no resource errors then try this step also In Eclipse :

    1. Select Help > check Updates.
    2. Select the Installed Software tab.
    3. Click Update.

    If an update for ADT is available, select it and clickFinish. Restart Eclipse.

  • Right click on your project in Package explorer in Eclipse. You will get a number of options. Go to Android Tools-> Fix Project Properties so see if that helps.
  • You should have errors indicating that R cannot be resolved to a variable. Right click on your project from the Package Explorer and select Build Project. Be sure Build Automatically option is turned off (uncheck in Project > Build Automatically).

Upvotes: 0

Related Questions