Raymond P
Raymond P

Reputation: 752

Eclipse is telling me resource already exists, while it doesn't

I have a problem with a weird bug in Eclipse. While editing some button's ID, for some reason Eclipse closed without giving any warning. So I restarted Eclipse, beeing annoyed since I didn't save my edits and everything was back to my last save. So I started renaming the buttons again, but now Eclipse tells me the resource ID already exists, but it doesn't. So I tried cleaning the project, but the problem remains. R.Java keeps those ID's even if they are removed from my project. So I checked my workspace files using Notepad++, but those ID's are not there any more. So anyone who has a clue why those ID's keep popping up in R.Java while there are not present in my project viewer or even the files itself?

Upvotes: 0

Views: 5968

Answers (2)

Raymond P
Raymond P

Reputation: 752

I figured it out! This my own mistake, I changed the ID of buttons, that had the standard names, eg button1, button2 etc. I left the update references box checked, but in the other XML files there where some buttons that still had the standard ID's. So they 2 got updated to the new names. So with my second edit, those where left having the old id.

Upvotes: 0

J.G.Sebring
J.G.Sebring

Reputation: 5964

Generally when one encounter ID-related problems the no brainer fix is to simply clean project. Also clean any included project libraries (if applicable) as they too have a generated R.java file with ID's.

Sometimes Eclipse auto-imports android.R.java causing problems - this is not a file you want to import but instead you want your own R.java, your.project.R.

If this doesn't help, the problem is often that the project does not build properly, therefore for not generating the mentioned R.java. Check your resources files, most likely some xml-file is invalid and needs attention before the project builds.

  • Clean project
  • Make sure android.R is not imported
  • Make sure your.project.R is imported
  • If R.java isn't generated, look for invalid xml in res folder
  • Sometimes restarting Eclipse does help, and you can't clean the project too many times

Upvotes: 1

Related Questions