Cannot create R.java b/c project has errors...errors result from lack of R.java
edit: This is an Android project. My problem arose when I added a new .wav file to my 'raw' folder.
I seem to have gotten into an endless loop in Eclipse. I deleted my R.java file from my project. Choosing to "Clean" or "Build Project" has no effect (i.e. doesn't generate an R.java file, or put anything into the 'gen' folder, or create any .class files in the 'assets' folder).
I don't have the wrong pack开发者_开发问答age name in any of my classes or in my manifest.
I don't have any errors in any of my .xml files.
Every reference to 'R' in my classes are marked as errors, because the R.java file does not exist.
What can I do??
Try deleting the wav file first. If it doesn't fix your problem, look under problems tab and it will give you a direction on what to do. A wav file under res/ shouldn't produce any problems, just make sure its name is valid in Java (don't use -, for example).
I solved this problem creating a blank project and copying the folder "gen" from this project to others projects. After that I rebuilt all projects and Eclipse automatically replaced the R.java
file.
if you rebuild it is there any error message on the console? or are you using capital letters or other special characters in your wav file?
Another issue I noticed, it seems that after closing and re-opening eclipse with a slightly invalid XML file, the XML was no longer recognised as having an error, but R.java
refused to be generated correctly.
The offending XML attribute was:
<RelativeLayout ...
android:layout_alignRight="+id/">
In hindsight, I had been intending to complete this with a valid id but I exited the program before I had finished. Eclipse did not pick up the error when I restarted later, except to generate an invalid R.java
with a missing VariableDeclaratorId
(and no indication as to what caused it).
精彩评论