Fixed: R cannot be resolved to a variable

I encountered this problem when I was making a new project on my eclipse workspace. I got a red underline on “R” in this part of my code


So here’s what I did to fix this issue. Go to Project Properties > Java Build Path > Tick Android Version Checkbox

Then if your workspace does not build automatically…

Properties again > Build Project

After that, all went back to normal. :)
Thanks for reading this Fixed: R cannot be resolved to a variable!

The Code of a Ninja Resources

  • Anonymous

    Resolving R error: I in general try to save, debug or run again n again to remove this error….nice solution :-)

  • Mike Dalisay

    Thanks for your suggestion and comment Anonymous :)

  • Anonymous

    Great tip. Ticking the Android checkbox fixed the problem. Thanks!

  • Mike Dalisay

    You’re welcome @Anonymous. :)

  • Tushar

    wow… Finally it worked thanks you are genius.
    (Yesterday i updated my eclipse version into Juno and also the android sdk to 4.1 after that i was facing the ‘R cannot be resolved to a variable’ problem)
    But now its Absolutely Fine..

    :) thanks :)

  • Anonymous

    though that is a great solution. it did not work for me.