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!
24 responses to “Fixed: R cannot be resolved to a variable”
Resolving R error: I in general try to save, debug or run again n again to remove this error….nice solution :-)
Thanks for your suggestion and comment Anonymous :)
Great tip. Ticking the Android checkbox fixed the problem. Thanks!
You’re welcome @Anonymous. :)
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 :)
though that is a great solution. it did not work for me.
This helped a ton with my file path problem when trying to add an audio file [ex: mp1 = MediaPlayer.create(this, R.raw.audiofile); but only after I made sure that the audio file name was in ALL lowercase. The error popped up only while the audio name had a cap in it like: audioFile.mp3. Until the mp3 name was switched to all lowercase the path could not be resolved.
I’m glad it helped with your situation @Tarielen:disqus :)
thanks for the help………..by the way how did u got to know this?
Hi @disqus_LcBdEFUw9N:disqus, back then I was trying every possible solution, and it lead me to this. :)
Many thanks. Working through the “getting started” examples and your fix solved the problem.
Glad it helped Kristian :)
I do it, but didn’t resolve my problem.
still has error!
Hi @4d58c697aa97c76daab28464fdab8f02:disqus, would you give us any error messages you see?
It works! Thanks for sharing this helpful tip.
You’re welcome @fa32097897144850173ec5164c5b36fe:disqus! Thanks for letting us know it still works!
Thanks for giving your feedback @gurpreethanjra:disqus!
Tks bro, only this fixed to me.
You’re welcome @Koalan, good to know it helped!
This was a great solution, although it didnt work for me!! :)
R cannot be resolved to a variable
Unknown error merging manifest
The two error which make feel like hell
I had this problem for weeks ! I tried every thing that was in the websites ! and now the problems are gone ! i didn’t get what happened ! but so happy … thank u a lot !
Hello @disqus_etZQQ0XZre:disqus, I’m glad this blog post helped you! You’re welcome :)