Coyttl
Coyttl

Reputation: 534

Eclipse - Android not auto-generating R class

have an odd one..

Using Eclipse Juno, and everything was working fine for the last couple months. At some point yesterday, while Eclipse was cleaning my project, something crashed - popped up the Windows error reporting. (Didn't catch the name of what crashed..)

Now, I have no R.java class in /gen, and nothing I've tried will generate it. On top of that, when doing a clean rebuild of the project, the Output window remains blank. (No errors, no status message.. nothing.)

Tried just about everything - including the latest which included reinstalling Eclipse and then ADT. Still hadn't helped. (I have NOT tried clearing the workspace metadata yet, will do that soon.)

Any thoughts on what else to check?

--Fox.

Edit: Updating a random file - either .java or an XML layout/drawable does not have any effect, still nothing. Also, removing saved preferences from workspace .metdata data didn't have an effect either.

Edit 2: Okay - not sure WHY it was happening, but creating a new project and the issue was corrected.

So somehow either the project settings (.settings or project.settings) must have gotten corrupted. I have the origianl project still, and am curious to see why it happened, but creating a new project and copying sources and resources over, and no more issue.

Thanks to all that offered comments - goes to show that any kind of little corruption can cause strange things to happen.

Upvotes: 9

Views: 12692

Answers (5)

Kenneth Hippolite
Kenneth Hippolite

Reputation: 96

For me it ended up being gen/com/(appname)/R.java missing. Not in my recycle bin, not anywhere... just took a surprise vacation and never returned.

I had a backup copy in a different folder. Copied it back and all's good now

Upvotes: 0

hairysocks
hairysocks

Reputation: 131

I found this happened after updating my Android SDK Manager and related eclipse plugins. I am running in Ubuntu, and it would not let me update the plugins unless I ran as the root user (using "sudo eclipse")

This left some of the Android SDK Manager items, and the eclipse plugins, owned by root. This stopped the "clean" working on the project - it must have been something that had been added as the root user, and not accessible as my normal user.

I had to "chown" my eclipse directory and my Android SDK Manager directory so it was owned again by my normal user:

cd /home/myacct/android-sdk/
chown -R myacct:myacct *

After this the clean option worked, and R was regenerated.

Upvotes: 1

alexismorin
alexismorin

Reputation: 856

This was it for me: In your AndroidManifest.xml file, make sure that you have the SDK installed for the version number in android:minSdkVersion="##".

You can install SDKs from the Android SDK Manager, found under Window -> Android SDK Manager in Eclipse / ADT.

Upvotes: 0

loonis
loonis

Reputation: 1487

If you don't have any errors in your xml files, you tried to reboot your eclipse, your emulator, then open the sdk manager and apply all update. My R have finally been generated.

Upvotes: 5

InsaurraldeAP
InsaurraldeAP

Reputation: 682

The reason in 99% of the cases is that you are missspelling something in some xml file. The R class file won't appear until all xml files are correct.

I suggest look carefully into your XMLs for a very small syntax error.

Or try taking off 1 by 1, until you figure it out wich one is the problematic.

:) kind of annoying, i know.

Upvotes: 23

Related Questions