0

I'm working on an Android app in Eclipse. After making certain changes to one of my Activity classes layouts and cleaning/rebuilding the code at first I get an "error executing aapt return code 1" error, after which the R class does not get generated in the gen/ folder.

While searching for answers online I found out that some users experienced xml errors resulting in project corruption and inability of generating the R class. I compared my project folder before and after the modification, using an autocompare tool, and all of the xml files (and all the other files) are identical. The only difference is that there are some files generated in the bin/ folder in the 'before' instance that don't exist in the 'after' instance. Anyone know how to fix this?

Vee6
  • 1,527
  • 3
  • 21
  • 40
  • Copy the important files, delete the project, make a new project with same name, paste the files.. happened to me more than once.. I used to fix it this way – Sharp Edge Feb 22 '14 at 23:08
  • I can confirm this works :). however I can't do it everytime I modify UI elements. sometimes I modify stuff, and when I don't get this weird R glitch the modifications at runtime don't always mirror what I actually did in the graphic layout editor.. – Vee6 Feb 23 '14 at 05:44

2 Answers2

0

Sometimes it helps to delete the whole gen directory, and make sure you have no errors in your project, add or remove one of your strings. and rerun the project in the simulator.

Tomas
  • 156
  • 7
0

From your question there is too little info to pinpoint any problems but it sounds like it might be a syntax or a formatting problem with the XMLs. Is your Eclipse console complaining about anything or Package Explorer showing any red crosses?

luckylukein
  • 819
  • 1
  • 7
  • 17
  • None at all. The fact is that before modifying the xml files they worked and generated R correctly. the modification was one generated by eclipse (I took a button from an Activity and dragged it somewhere else). – Vee6 Feb 23 '14 at 05:29
  • this is before: android:layout_alignLeft="@+id/textViewCountdown" android:layout_below="@+id/textViewCountdown" android:layout_marginLeft="46dp" android:layout_marginTop="122dp" – Vee6 Feb 23 '14 at 05:30
  • and this after: android:layout_below="@+id/textViewCountdown" android:layout_marginLeft="76dp" android:layout_marginTop="89dp" android:layout_toRightOf="@+id/textViewCountdown" and this after: android:layout_below="@+id/textViewCountdown" android:layout_marginLeft="76dp" android:layout_marginTop="89dp" android:layout_toRightOf="@+id/textViewCountdown" – Vee6 Feb 23 '14 at 05:31
  • Could you post the full layout file that you are having problems with? I think there could be more than one problems. From the looks of it, you are using a RelativeLayout and by using the "android:layout_toRightOf" property might be trying to arrange a view to the right to another view (thats defined in the Xml with a @+id) so just use "@id/" instead of "@+id". What i mean is, it should be android:layout_toRightOf="@id/textViewCountdown". Let me help you more! Post the full XML layout and I can take a look. :) – luckylukein Feb 23 '14 at 07:49
  • hey, thanks for being helpful. So, I deleted the entire modified project, unzipped in again (I didn't built it from scratch), and while it runs on my phone, when I clean and rebuild it, it gives me the same errors, meaning it wasn't ok to begin with. Anyway, here is the xml. I posted it on a separate site, since it's too big to be put here: http://justpaste.it/eieg – Vee6 Feb 23 '14 at 11:52