tags:

views:

1030

answers:

7

I've changed target for my application from 1.6 to 1.5, and now the generated R class has gone.

What's the way to re-generate it (I'm using Eclipse with DDMS plugin)?

I tried adding/editing xml files, I have "Build automatically" option enabled... I even restarted computer, but still no R class.

A: 

Try to add a new "Android XML file" to, for example, the /res/layout folder. This might cause the plugin to to regenerate the R class.

Richard Szalay
Tried this, but nothing happened (I even restarted Eclipse before adding the xml file)
zorglub76
A: 

You can just modify any xml files in /res folder and even just add a space and save, it will be regenerated.

Cytown
I used to do this, but now it doesn't work... Still no R class..
zorglub76
A: 

You can just delete the R.java file from your project and it will regenerate assuming you have build automatically enabled. If you do not have build automatically enabled simply goto project->build all

steve
I have this enabled...
zorglub76
Sorry I didnt read correctly!
steve
+2  A: 

Ok, I fixed it:

When I changed manifest to target 1.5 version, million errors appeared and only one wasn't related to inexistance of R class - in manifest file attributes "targetSdkVersion" and "maxSdkVersion" did not exist in sdk 1.5

Because of this R class was not able to generate.

zorglub76
+2  A: 

You can also right click on the project -> Android Tools -> Fix Project Properties. That should cause the R.java class to be re-generated.

Erich Douglass
+1  A: 

I had a similar problem where the R.java file was not being regenerated after I'd added some icons and layout files. I tried cleaning and rebuilding and things got worse since then the original R.java file was gone and still wasn't regenerated. Eventually it dawned on me that there must be compiler errors for the compiler that generates R.java and we aren't being shown those in the console. Fortunately, I had noticed earlier that a) it's an error if one .xml file refers to another which is non-existent and b) it's an error to have upper case letters in your file names (why is that forbidden, I LOVE camel case).

Anyways, after renaming my icons and .xml files to all lowercase and then fixing all the references inside the .xml files, voila, R.java was regenerated. Just in time to feel good when I stopped for lunch :-)

John Klippenstein
A: 

If you use Intellij IDEA you can click Build - Rebuild Project

Georgy Gobozov