Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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)