Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

R cannot be resolved to a variable

I am running Ubuntu 12.04.

Last night I had the Java ADT working, and running the first part of the Android app track here. However, after leaving the ADT and re-entering it I now get a few error messages

R cannot be resolved to a variable MainActivity.java

R cannot be resolved to a variable MainActivity.java

These errors are preventing the app from playing.

What is going on?

1 Answer

In eclipse the R file (which is an automatically generated resource id file) is rebuilt every so often. If there is another error in your program R will not build and so eclipse will tell you it doesn't exist. A good way to refresh the project is to clean it. (In eclipse, project, clean, clean all)