1

I cannot fix:

"R cannot be resolved to a variable"

I have tried cleaning, building, I have deleted and made sure that any "java.R" imports are missing or whatever but I STILL cannot seem to squash the bugger!

Any reference to id's or layouts don't work and it just feeds back an error.

Cœur
  • 37,241
  • 25
  • 195
  • 267
MPKenning
  • 569
  • 1
  • 7
  • 22
  • duplicate of [R cannot be resolved - Android error](http://stackoverflow.com/questions/885009/r-cannot-be-resolved-android-error) – Alex Lockwood Jul 07 '12 at 22:48
  • Make sure you've cleaned your project and all libraries involved. Also check through the `Problems` tab (Window -> Show View -> Problems) for any non-`R`-related errors, and fix them best you can. Even just one might cause an `R` error. – Cat Jul 07 '12 at 22:48
  • @Alex, I've googled and google and searched and searched and nothing past page 2 of Google has helped. – MPKenning Jul 07 '12 at 22:49
  • @Soxxeh; the only problems are R-related problems. – MPKenning Jul 07 '12 at 22:50

3 Answers3

2

Do any of the files in your resource folders have capital letters in them? Capital letters aren't allowed.

This hung me up once....

brainmurphy1
  • 1,082
  • 1
  • 19
  • 24
0

Try the following things:

  • Make sure none of the XML files (menus, layouts, etc.) has any errors. Those prevent the R fropm being genreated
  • Delete the project from eclipse and import it again
  • Look for Android meta data files (i think those are in a .android folder) and delete those

hth..

Candlejack
  • 248
  • 1
  • 3
  • 15
0

Try the below steps to resolve the issue,It worked for me:

  1. Cleaning the project and then building it again. Closing project and then opening it again.
  2. Closing project and then opening it again.
  3. Going to Project Properties > Java Build Path > Tick Android Version Checkbox
  4. ensure no errors in XML files,Because errors in xml file Prevents the R.jave file to be created.
  5. try downloading the latest version of android SDK,if available.
user3009917
  • 113
  • 9