0

I have just re-install Eclipse and Android SDK because I had a problem where it said a APT file couldn't be found, so I tried to clean and now it states R is missing or something, so i re-installed created a blank project and still get the same error

setContentView(R.layout.activity_main);

R cannot be resolved to a variable

If anyone can help me fix this, it would be great :)

Canvas
  • 5,779
  • 9
  • 55
  • 98
  • Try making changes to any of the layout.xml file and save it. Example, try to add some view and assign id to it, then save and check to see if R.java is now generated or not. It generates / re generates the R.java file. – Chintan Soni May 30 '13 at 00:36
  • I hope you have already checked and tried all the answers given [here](http://stackoverflow.com/questions/7824730/r-cannot-be-resolved-to-a-variable) – Shobhit Puri May 30 '13 at 00:50
  • it's usually the problem with XML files – Srikanth Pai May 30 '13 at 02:03

2 Answers2

0

This usually happens to me when there's a build issue. In the menu check Window/Show View/Problems view for errors. Once they're solved, R will be available in the code.

kaviddiss
  • 594
  • 4
  • 9
0

Make some change in your xml file and save project R.java file created Make sure it's selected Project -> Build Automatically

Amsheer
  • 7,046
  • 8
  • 47
  • 81