views:

66

answers:

3

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?

+1  A: 

The R file will not be generated unless there are not error in the /res/ folder.

If there are not errors in the /res/ folder, try removing the gen folder and then right click on the project -> android -> fix android settings.

Macarse
can't find menu entry: project -> android. only project -> properties -> android, but thats probably not what you meant.
lgwest
the only thing in the res folder is the warning about "No Grammar constraint ..." is that the problem? I don't know why that warning suddenly showed up, it wasn't there from start?
lgwest
@Igwest: don't think so :(
Macarse
Sorry my misstake. It was error in the res folder. But it took a while for me to realize that. All answers are correct, have to pick one. The warning "No grammar constraints ..." dissapeared when I right clicked on all .xml files and selected Validate.
lgwest
+1  A: 

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.

Sephy
+1  A: 

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

JackKnifeZero