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 trialJohan Nurmilehto
860 PointsMainActivity.java
Whenever I start up a new android project I get two errors in MainActivity. Those are that R cannot be resolved to a variable (so I import android.r) but now I get and error saying that main cannot be resolved or is not a field.
Im stuck and have no clue what the problem is.
3 Answers
Liam Peters
8,792 PointsHi, do you have more than one activity? In the eclipse errors section is there more than one error? The R build file will always error if there are errors elsewhere in your code. A good way to check this is to "clean" your projects. (In eclipse, under the project menu item, click "clean". This will rebuild and reassociate any cached relationships between files. Then you will hopefully see what the real error is. It would help to post the code you are having issues with. Look at the "Markdown Cheatsheet" link below the comment box to see how to easily paste formatted code!
Johan Nurmilehto
860 PointsI had just one activity and those two errors I mentioned, the weird thing was that I got those errors on startup. So I didn't write a single line of code myself. I also tried clean with no luck so I just gave up and reinstalled eclipse and the plugins and now its working. Computers huh
Liam Peters
8,792 PointsAh, ok, glad you got that sorted! Yeah they can be as moody as teenagers sometimes :)