codeofaninja
website

Fixed: R cannot be resolved to a variable

Photo of Mike Dalisay
Modified Tuesday, May 31, 2011
by - @ninjazhai
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. :)
For FREE programming tutorials, click the red button below and subscribe! :)
Thanks for the comments!
 
 
Fundamentals
"First do it, then do it right, then do it better."
~ Addy Osmani
"Talk is cheap. Show me the code."
~ Linus Torvalds
Let's Stay Connected!
g+ r
Android app on Google Play
© 2011-2014 The Code Of A Ninja. All rights reserved. Proudly Powered by Google Blogger. Images, logos, marks or names mentioned herein are the property of their respective owners.