I've found out that my R.java is never updated, so it doesn't contain information about my new resources, so I decided to delete it and thought that Eclipse would generate a new one. But that didn't happen, and I don't have R.java now. How can I regenerate one?
I'm using Windows 7.
From one of the comments: "Doing Project -> Clean is what caused the problem for me. Cleaning deletes R.java...and for whatever reason the plugin is not regenerating the file."
If your R.java isn't getting generated, one of the solutions is to delete the layout file named "blabla.out.xml".
After deleting this file, try cleaning the project from menu Project -> Clean.
I changed my layout XML file name and found out later that of the XML file (widget provider in this case) still refers to the old layout XML which doesn't exist, and that prevented the auto generation/correction of R class.
You 100% have an error in an XML-file, but the XML verification does not show you the error. This is the reason why you need to check your XML files first!
As a generalization of Glaux's answer, if you have any errors in the
res
directory, then R.java may not generate - even if you clean and rebuild. Resolve those errors first.As an example: when you add an image file of say, "myimage-2.jpg", the system will consider this an error, since file names are limited to alphanumeric values. Do a refresh on your 'res' directory after adding any files and watch the output in your console window for any file name warnings.
R.java will never be generated if there are any errors in the
res
folder. For example, in the drawable subfolder there are two files which have the same name, one is icon.png and the other is icon.html.You can see some error in the Eclipse console log window which is saying "Resource entry icon is already defined.". After deleting icon.html, you can clean or just delete the
gen
folder. You will find that R.java is created.All of these answers could not work if you use Maven. The solution for me was to add
to the configuration section of android-maven-plugin.