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
The package name in the manifest needs to be the same as the one in the /src
folder, the /gen
folder package will be automatically reproduced.
Observe the name of package in the /gen
folder. In my case it was different than the one in the /src
folder.
The package referenced in the manifest was that of the /gen
folder.
I attempted to add a package with the name of the /src
folder to the /gen
folder too see what would've happened, but this did not solve the issue. I proceeded then to remove the package name that was not the same as the package name of the /src
folder. This package with the name that did not correspond to the /src
folder was recreated as soon as I removed it.
Since the package reference in the manifest corresponded to the one that was being senselessly recreated and that did not correspond with the package in the /src
folder, this prompted to rename package = "oldPackage"
with the package = "srcFolderPackage"
.
All of these answers could not work if you use Maven. The solution for me was to add
<genDirectory>${project.basedir}/gen</genDirectory>
to the configuration section of android-maven-plugin.
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've found that any file that has capital letters in the res
folder will create this error. This happened to me with a PNG file I added and forgot about.
After reading through many posts and YouTube videos, I found that each of us have R.java
missing for different reasons.
Here's how I fixed this in Eclipse:
gen
folder manually and save. The following message will display and your file will automatically be rewritten:
R.java was modified manually! Reverting to generated version!
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.