0

Recently my android program won't generate the auto-generated R.java file under gen in my android project. I tried doing Project->Clean and it still doesn't work. I also restarted eclipse multiple times.

Any Ideas?

rogcg
  • 10,451
  • 20
  • 91
  • 133
Peter
  • 5,071
  • 24
  • 79
  • 115

4 Answers4

7

Make sure you don't have any errors* under your Problems tab in Eclipse. Try to use Fix Project Properties under Android Tools when your right click on your project.

If that doesn't fix your problem, try modifying your AndroidManifest.xml (just add a space and save). I've heard that will force the R.java to rebuild.

* except for errors that says R cannot be resolved to a variable - these errors will go away once you correct other errors and force R.java to rebuild.

ADTC
  • 8,999
  • 5
  • 68
  • 93
Haphazard
  • 10,900
  • 6
  • 43
  • 55
  • The first problem says: Description: Resource Path Location older/gen already exists but is not a source folder. Convert to a source folder or rename it. – Peter May 01 '11 at 01:04
  • @Peter sounds like you have to fix up your folder structure. – Haphazard May 01 '11 at 01:17
  • I cant find the R.java anywhere though, how could i find it? – Peter May 01 '11 at 01:19
  • The problem has nothing to with the R.java, but when you have errors in your project, the R will not regenerate.. so fix up the problems under the Problems tab and, once they are gone, you will get your R.java back. – Haphazard May 01 '11 at 01:25
  • Refreshing the project with F5 will cause the R.java file to be regenerated too. – Robert Massaioli May 01 '11 at 02:13
  • Modifying and saving the manifest did the trick for me. Thanks! – Peter Ajtai Nov 10 '11 at 17:31
  • Well what if your errors in the Problems tab have to do with the R file being missing? What then?? – IgorGanapolsky Dec 01 '11 at 20:09
  • Wow after some serious time spent searching for answers, resolving some problems that I didn't notice in the problems tab solved everything, you're a life saver =) – flicflac Jun 05 '13 at 00:15
  • Make sure eclipse is updated to the latest version, none of the previous solutions worked for me until I performed update! – Trent Seed Jul 25 '13 at 23:44
  • 1
    _"Make sure you don't have any errors"_ - **except** for errors that says *R cannot be resolved to a variable* - these errors will go away once you correct other errors and force `R.java` to rebuild. – ADTC Nov 24 '13 at 04:56
1

Check to see if you have any errors in any of your resource XML files. If you do, comment out the problem area, clean and rebuild. If you then get your R.java to autogenerate focus on trying to figure out what caused that XML error.

Corey Sunwold
  • 10,194
  • 6
  • 51
  • 55
  • I did have an error in one of my XML files but i fixed it and R.java still has not autogenerated – Peter May 01 '11 at 01:12
0

I had this problem. I updated Android SDK and Eclipse. After a clean R.java reappeared.

Tash Pemhiwa
  • 7,590
  • 4
  • 45
  • 49
Joris
  • 486
  • 7
  • 10
0

Since I am unable to improve the accepted answer due to persistent peer review rejections, I will have to post my proposed changes to the accepted answer as a separate answer.
Credits for first two paragraphs go to the user Haphazard.

Make sure you don't have any errors* under your Problems tab in Eclipse. Try to Fix Project Properties under Android Tools when your right click on your project.

If that doesn't fix your problem, try modifying your AndroidManifest.xml (just add/remove a space and save). I've heard that will force the R.java to rebuild.

* except for errors that says R cannot be resolved to a variable - these errors will go away once you correct other errors and force R.java to rebuild.

Community
  • 1
  • 1
ADTC
  • 8,999
  • 5
  • 68
  • 93