0

I'm trying to learn how to develop an Android App from scratch using Eclipse, but I keep running into the "R cannot be resolved into a variable" error. I tried everything from completely removing Eclipse and downloading it again, to deleting my project and workspace and starting over, but I just cannot get away from this error. The thing is, it's coming up without me even doing anything. I just start a new Android project and it opens with this error so I can't move forward in learning this stuff.

Any ideas on what I can do? Keep in mind I'm at the absolute beginning of learning how to work with Eclipse, so if you have a possible solution, I'd really appreciate a step-by-step answer.

Thank you!

EDIT: As it turns out, I didn't have any of the build-tools installed. I remember installing them but I have no idea what happened and they were just not listed as installed. After re-installing, I'm good to go. Thanks for the help everyone!

vashp2029
  • 25
  • 5

4 Answers4

0

Right click on your project and clean it, if there are any errors it will prompt you or else the R.java file will be created in your gen folder and imported in your project.

Apoorv
  • 13,470
  • 4
  • 27
  • 33
  • I should have mentioned that I tried this method (found it on a different thread on SO). Anyway, I tried it again just to be sure, and still no luck. – vashp2029 Dec 13 '13 at 05:12
  • Is the `R.java` file present in your imports? – Apoorv Dec 13 '13 at 05:13
  • If you mean under the gen folder, then no, there's nothing. What am I doing wrong? – vashp2029 Dec 13 '13 at 05:17
  • Check out if this helps [R.java file not generated](http://stackoverflow.com/questions/2757107/developing-for-android-in-eclipse-r-java-not-generating) – Apoorv Dec 13 '13 at 05:19
0

If there is any problem with the xml file in android, then R.java won't be generated. Please make sure that you don't have any error in xml file, then clean the project by clicking clean button in "Project" option and click "Build Project", Build Automatically is not selected. This should solve your problem. Best of luck.

Vikas B L
  • 397
  • 1
  • 10
0

You have updated the android sdk but not updated the adt to match with it.

You can update the adt from here

You might need to update the software source for your adt update

Go to eclipse > help > Check for updates.

It should list the latest update of adt. If it is not working try this

go to eclipse > help > Install new software

Click on add

add this url : https://dl-ssl.google.com/android/eclipse/

give it any name.

It will list the updates available- which should ideally be adt 20.xx

Eclipse will restart and hopefully everything should work fine for you.

vinay Maneti
  • 1,447
  • 1
  • 23
  • 31
  • I did that initially when I was going through a tutorial that explained how to get started. I tried it again just to be sure and still no luck. No updates were available since I already have them installed. – vashp2029 Dec 13 '13 at 05:33
0

Try to fix all error in your XML file. Look drawable, layout and other res folders closely for any error.

If it does not fix your problem then try THIS answer :

Community
  • 1
  • 1
Vipul Purohit
  • 9,807
  • 6
  • 53
  • 76