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
yilzer
4,601 PointsEverytime Eclipse error by start-up after a clean shut down
Hi Guys,
I have the following problem, maybe one of you have a solution for this. When i close my Eclipse my code contains no errors and looks fine, but everytime when i start eclipse again my MainActivity.java contains errors about the "import.android.R; This error is showen: R cannot be resolved to a variable. I tried to clean my project but this don't work for me. Sometimes when i restart eclipse again and again they dissapear. So weird, is there any solution for this problem?
Tnx in Advance
6 Answers
cbcbcb
16,560 PointsRight click your R file and delete it. Then rebuild. If that doesn't work then you have an error in one of your xml files....trust me
cbcbcb
16,560 PointsDo not overlook the xml. Open all of your res folders and see if there is an x next to any of the files nested within that directory tree
cbcbcb
16,560 PointsDo not overlook the xml. Open all of your res folders and see if there is an x next to any of the files nested within that directory tree
cbcbcb
16,560 PointsOh by the way not sure if you know but if you do sorry jsut wanted to make sure.......R.java is under project/gen/...
Also I don't know if you created any packages in your source directory at the top level....but one thing that has gotten me before is that my R file is I always have a somemodule/models subpackage and a somemodule/controllers subpack etc etc..... well what can happen is that your R.java file can end up under a subpackage that your editor is not aware of. So I had to import than go back and change it each time to import com.christopherbasinger.reponame.submodulename.R; although of course to get around this you could just do an import all from the toplevel at your domain name down but whatever
yilzer
4,601 PointsTnx for you response! I realised that my R.java was missing in the gen file, so I generated a new one and now everything works fine!
cbcbcb
16,560 PointsNo problem good luck
cbcbcb
16,560 PointsCan we close this question? I think it has been answered.