0

I know this has been asked before, before you thumb down read my full post, then feel free to thumb down, I'm sure I have a few coming. ;)

So I just started a new Android project, I've made several in the past, but this time from the start the R file was not found and I get "R cannot be Resolved to a variable".

Figuring this is most likely a common problem I checked StackOverflow to see what if others have solved the problem, and lots have, but almost all have to do with something the user did with renaming something.

My problem is that I haven't even started yet and just with the code auto generated from eclipse It already shows these errors.

What I've already tried. 1 Project-> clean before and after every other thing I tried 2 check to see if any res files had unsupported charters 3 checked for updates (SDK Eclipse ADT) 4 checked that I had Andriod build tools 5 Project properties -> build path is in correct order with everything that needs be checked. 6 Package is spelled correctly in the AndroidManifest. 7 Rebuilt Project 8 Every thing suggested here - "R cannot be resolved to a variable"?

I know this question has been asked a million times, but I can not find an answer that works for me and I'm frustrated enough to re-post a million and 1st question.

If you have any solutions other than the list above let me know, I will continue searching the interwebs for more solutions in the mean time.

Community
  • 1
  • 1
Darrellii
  • 47
  • 1
  • 6

5 Answers5

1

In my experience the most common cause of the R file not being generated is an error in your source code. Usually in your layout XML files. Make sure that you do not have any errors in any of the XML files.

wyoskibum
  • 1,869
  • 2
  • 23
  • 43
  • I don't, All of the code I have right now is auto generated from eclipse and there is nothing wrong with any of it... – Darrellii Oct 04 '13 at 19:29
  • If your code was so perfect then it would be working. All it takes is an accidental keystroke in auto generated code to break it. Look at each and every XML file and look for an error. – wyoskibum Oct 04 '13 at 23:11
1

You just make one R.java file manually under gen folder under your package. Now try to compile. I expect to automatically R.java will be modified. I had the same problem once.

AshMv
  • 392
  • 2
  • 12
1

"R" in android is a class TODO auto-generated, this means that everytime you build your project R.java is compiled again. I think that probably you have some problem with your SDK. I advise you to control Manager SDK if you are using Eclipse or tryng to launch ant from your terminal in such a way to verify that Ant tool is installed on your machine, if no the R.java cannot be generated.

Emisilve86
  • 354
  • 2
  • 8
1

You can just make a new project, it won't be to much work if you haven't edited this one yet.

superuser
  • 731
  • 10
  • 28
1

Please try changing your workspace on starting eclipse. And create a new project and attempt.

AshMv
  • 392
  • 2
  • 12