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
Allan Evans
9,501 PointsR.java not being generated
Hey guys, I've been having a weird issue in eclipse. You know how you regenerate the R.java file when you use the clean option, well when tried that today it removed the R.java file but didn't make a new one. I have checked out my xml files and there aren't any errors but still the R.java file doesn't come back. I have looked on the web for a solution but the majority of the solutions are things I have already tried and checked. Let me know if anyone else has dealt with this, going slightly insane trying to figure this one out. Thanks
4 Answers
Pavlos Isaris
10,863 PointsIf you have a corrupt XML-file and try to rebuild your R.* it will fail. You should go through your xml-files and make sure that they are all error-free. It's likely you have a misspelling or other small problem somewhere that prevents the build.
Then, Test the following operations on your project :
1.In the project properties (eclipse) -> java build path -> order and export make sure that all your jars in the libs folder are checked.
- "Android Tools -> Fix Project Properties"
- "Project -> Clean"
Allan Evans
9,501 PointsI ran lint:check for common error and corrected them all, used the tools fix project properties option, then cleaned the project and still no R.java file just a BuildConfig.java file. Everything is checked in the build path as well, this one has me good :O
Pavlos Isaris
10,863 PointsIn general, R.java is not generated due to some parsing issue from the XML resources. So check again for mistypes or such errors. Another solution might be to delete the entire "gen" folder and click Project->Clean so it re-generates. Finally, make sure that all .xml and image files names are lowercase.
Allan Evans
9,501 PointsWow finally got it, and it was a weird solution. Watching the console messages when I would try to clean and generate it showed an 'aapt' error. This guy usually shows up when a xml file is referencing a file that doesn't exist. What was worse was that there was no error indication besides that and it didn't give an idea where the error was besides in the res folders. So after some searching, found the file in the menu folder and removed the file from the folder and now the R.java generates properly. Thanks for the help.