2

The title says most, but I have created a new project in Eclipse. I have everything set up, and as soon as I create a new Android Application Project, once everything has Generated there are 2 Errors: both "R cannot be resolved to a Variable", on Line 19 and Line 12. In the Video Tutorial Series I am watching it says there should be a file called R.java in the gen folder, but there isn't, just an empty folder. The Android project is completely new. Here are some of the things I have tried after googling, none solved the Issue:

  • Clean Project
  • Uncheck/Re-Check Build Automatically
  • Build Project
  • Close/Open Project
  • Check XML files for Errors - only the Two Errors as mentioned above in the Error Log
  • add "import android.R.*"
  • Create R file manually (Add -> Class)

It is my first time writing an app in eclipse, I know there are a lot of questions like this but none seem to solve my problem. The Java Errors (R not resolved to a variable) Errors are the only errors, no errors in the XML or Anything.

So that you can check my project, I have put it in my Dropbox if you want to have a look at it in eclipse. Project Download Link

user2420318
  • 21
  • 1
  • 6
  • your package name in manifest as com.tnb.android.daniel but in src as com.example.daniel – Senthil May 25 '13 at 13:14
  • Try checking for the updated `Android Development Tools` and Android `ADT-Tools` again. Sometimes Eclipse needs to install updates in two batches and the second updates don't appear until only after you finish (install) the first batch. I just hit my head against the wall for the past 20 minutes due to this. – Dzhuneyt May 25 '13 at 13:25
  • http://stackoverflow.com/questions/16636039/java-lang-classnotfoundexception-after-changing-nothing-in-the-project-but-upgra/16636127#16636127. try this – Raghunandan May 25 '13 at 14:36

4 Answers4

3

You can create the new Project and then copy the contents of this project into the new one. This problem is with Eclipse. I recommend you to use Android Studio.

Adesh Atole
  • 766
  • 1
  • 8
  • 22
-1

What might help, would be to create a new project and transfer the current project to that one. When the R file is not created when creating a new project, try and re-download the development tools and sdk.

Luke Taylor
  • 9,481
  • 13
  • 41
  • 73
-1

I'm sure that the problem may be with your ADT tools in eclipse. Sometimes, this errors may occur due to some installation mistakes or some sort of software cracking problems. I also faced the same problem at my starting stage. The best thing that you can do is to move on with re-installation of ADT in you eclipse. It may help you. Try this!! Create you new Android Project and Enjoy buddy !!

thampi joseph
  • 700
  • 1
  • 8
  • 20
  • Even the guy says that he downloaded the ADT bundle and thus solved the problem. But, I got a negative mark for my answer. What's this friends? – thampi joseph May 05 '14 at 05:40
-1

I was having this exact problem, and found the solution after much headache.

In eclipse, find and click the button labelled Android SDK Manager (next to save, and all that jazz on the toolbar).

In the manager, make sure that under the "Tools" folder all of the relevant "Android SDK Build-tools" have been installed. Once they are, restart eclipse, and your R.java file should be generated. Hope that helps!