The automatic generation of the R class does not work anymore. I have tried Project -> Clean... A warning on all xml files has also showed up: “No grammar constraints (DTD or XML schema) detected for the document.” Maybe that is why the code generation have stoped. Any idea how to get the R class generated again?
9 Answers
As the other posts say, the /res folder mustn't have any files that have errors in them. If so then the R.class file cannot be generated. If the errors are fixed then the project should re-build and the R.class should generate. If not, I believe you can right-click on the project then Android Tools -> Fix Project Properties. I think that is what @Macarse was meaning by project -> android -> fix android settings. I didn't see those options but the Android Tools -> Fix Project Properties usually does the trick for me or sometimes cleaning the source works too (Right-click the project -> Source -> Clean up...).
Hope this helps you.
:)
Jack
Generally when you get this kind of error, that means that you have an error in one of your resources. Have you added a drawable, changed a layout, or added/modified any resource just before this happens?
For instance if you created a 9-patch drawable, you can't have the image.png and image.9.png at the same time in the drawable folder, it will create an error, and Eclipse will go crazy. Same thing If you made a mistake in a xml file, and saved it. Then the R class can't be generated as long as you have not corrected the file.
Also this can happen because of one of the folders are named wrong, and so compromising the android directory structure. In my case, I tried to generate the class R in many ways I saw here until I realized I had created a folder "res / drawble" instead of "res / drawable". Like magic, you just go to Project-> Clean with "Build Automatically" checked and it appeared.
I use Intellij IDEA and some day R class stopped generating (maybe, after update).
Setting “External build” checkmark in compiler preferences fixes the problem: