1

I think these posts are the best here on stackoverflow that are related to my issue:

“R cannot be resolved to a variable”?

R cannot be resolved - Android error

I tried every answer on those posts, but I still didnt fix my "R cannot be resolved to a variable" error. I'm really desperate at this point. The interesting part is that I had yesterday the same problem and I fixed it with the clean project + restart IDE method, but today it's not working. I never had this problem until I updated my ADT to ADT 21.1.0. I know that my res files are not allowed to have any errors, but they have some warnings. Are those warnings coausing the problem?

Community
  • 1
  • 1
Aksiom
  • 1,565
  • 4
  • 25
  • 39

2 Answers2

4

R.java is deleted whenever there exists any compile error in res/ folder or in AndroidManifest.xml file. You have to check every files in res/ folder and AndroidManifest.xml to fix the problem.

melvynkim
  • 1,655
  • 3
  • 25
  • 38
  • I have checked them 3 times now. No errors, only few warnings about Hardcoded string, Should use "sp" instead of "dp" for text sizes, Missing contentDescription attribute on image, etc. – Aksiom Mar 12 '13 at 11:37
  • @Aksiom It is very common to have absolutely no warnings and no errors and still have problems with "R.java cannot be resolved" problem. I know this can be frustrating, but you have to check line by line. – melvynkim Mar 12 '13 at 11:39
  • 1
    Yea i managed to find 2 errors after checking line by line, but that really sucks. I dont even want to imagine what if I had around 100 res files. Thank you for pushing me :) – Aksiom Mar 12 '13 at 11:56
  • Just downloaded FacebookSDK - tried to compile and - “R cannot be resolved to a variable” error. Create new empty project - “R cannot be resolved to a variable” error. even when open old working projects - same error. Te only difference is migrated from WindowsXP to Windows8 64 bit. – Kostadin May 16 '13 at 14:01
0

Sometimes it will happen when memory cache not cleared previous data . Just simply clear your project then it will worked .

procedure : In eclipse go project then you will see clear ...

then press clear and select your project and press ok . hope it will work. best of luck

misba
  • 1