CSS Includes

Tuesday, May 31, 2011

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

setContentView(R.layout.main);

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

Click to enlarge.


Then if your workspace does not build automatically…

Properties again > Build Project


After that, all went back to normal. :)
Thanks for sharing the post! :)
For FREE programming tutorials, enter your email below and subscribe! :)

6 comments:

Anonymous said...

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

Mike Dalisay said...

Thanks for your suggestion and comment Anonymous :)

Anonymous said...

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

Mike Dalisay said...

You're welcome @Anonymous. :)

Tushar said...

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 said...

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

Post a Comment

You can use http://pastebin.com/ or http://jsfiddle.net/ if you want to comment some codes.

Related Posts