Eclipse – R cannot be resolved to a variable

I’ve never really played with Android development too much, but I decided to give it a shot last night.  I found a few YouTube tutorials, but decided to start with Google’s Android dev tutorial.  I ran into a problem almost immediately, but my usual Google searches weren’t too helpful.  Rather than just give up and watch 80’s videos on youtube, I decided to tackle the problem.

Basically, the error message that I received was “R cannot be resolved to a variable” – there are pages after pages of questions with this exact phrase from Stack Overflow.  There were a few common steps recommended, including one where the user was instructed to “Clean” the project.  This advice actually works, but not if you just “Clean” according to the default settings.  The default is to “Clean All Projects” which did not work for me, but changing the setting to “Clean Selected” then selecting my project actually did work.

I’m guessing it’s a bug within Eclipse, but it took me an hour to figure out, and hopefully there’s a chance Google will look favorably upon this humble blog post and promote it to users who are having the same problem.

Leave a Reply

Your email address will not be published. Required fields are marked *