19

I have an Android application project that suddenly stopped to work. There is apparently no error, but when I try to launch, I get this:

Error executing aapt: return code 139

I tried to clean the project and its dependent library project, restarted Eclipse, updated to latest ADT and SDK versions, etc. but all failed. I also have this other error sometimes (without changing anything):

Error generating final archive: java.io.FileNotFoundException: .../bin/resources.ap_ does not exist

I'm completely lost.

MORE INFO

I spent hours to disassemble and reassemble everything piece by piece, and finally found what causes these errors, though I still don't understand anything better... I had a resource like this:

<resources>
<integer-array name="titi">
<item>@+id/toto</item>
</integer-array>
</resources>

I removed it and everything worked again... Of course the resource file had no error at all. Half a day lost for nothing, this Eclipse is driving me mad 8-/ Am I the only one?

Patrick
  • 3,578
  • 5
  • 31
  • 53
  • 1
    Got the same error after declaring an ID in a style. Must be something related to ID resources? – mxk Jan 21 '13 at 16:26
  • Just got the same error and spent quite a while tracking it down. For me, the issue is with a com.google.android.gms.maps.MapView and the id assigned to it. Giving it "mapview" works but "map" does not. Neither ID is used anywhere else in that specific layout but both are used in other layouts. I'm in the process of converting from using the old MapView class to the new one (all old instances were "mapview" for the ID and I've been making the new ones "map" to keep track). This must be some strange ID conflict bug? – Ian G. Clifton Jan 22 '13 at 23:42
  • Looks like my error happens if I don't have a view somewhere with an ID of "mapview." I've filed a bug: http://code.google.com/p/android/issues/detail?id=43100 – Ian G. Clifton Jan 23 '13 at 00:28
  • @Patrick I think you can mark my answer as the correct answer. – Nima Jul 27 '14 at 18:43

5 Answers5

38

Just had the same issue and the problem was that I had a menu file inside the menu folder which had an android:title="@string/.." that did not exist in my strings file. After adding it and doing a Project > Clean the problem is gone.

Nima
  • 6,383
  • 7
  • 46
  • 68
  • 1
    Confirmed. I just had the same crash. I used "@string/missing_string" in menu XML. – WindRider Jan 22 '14 at 20:23
  • 4
    Indeed. It seems I cleaned up (saw no need) of autogenerated string: `Settings` in strings.xml. Putting it back solved my problem. – ronnydw Jan 23 '14 at 19:53
  • 2
    Thanks, had the exact same problem and its tough to track down on larger projects! – Jay Tomten Jan 28 '14 at 01:12
  • I had a very similar symptom, although the error code was corrupt, but sure enough, the last thing I did was add a menu with a title pointing to a nonexistent string. – Jay Carlton Feb 16 '14 at 03:37
  • 1
    Had the same problem with a missing drawable resource in a menu.xml file. I fixed it and the error was gone! Thanks a lot for this information! – david.schreiber Mar 12 '14 at 10:35
5

Don't use @+id/... here:

<?xml version="1.0" encoding="utf-8"?>    
<resources>
    <integer-array name="titi">
    <Item>@+id/Toto</item>
    </integer-array>
</resources>

@+id/... can only be used in layout resources.

Use @id/... and generate ids with help resource file if needed: res/values/ids.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <item type="id" name="toto" />
</resources>

http://developer.android.com/guide/topics/resources/more-resources.html#Id

Sensei
  • 396
  • 6
  • 7
2

I just moved a project away from using the Android v7 appcompat support library and encountered this problem. Turns out that I had a bunch of menu resource files that were still using the appcompat version of some of their properties.

I used to have this:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:compat="http://schemas.android.com/apk/res-auto">
    <item
        android:id="@+id/conversations_activity_menu_contacts"
        android:title="@string/contacts"
        compat:showAsAction="ifRoom|withText" />
</menu>

But then corrected the problem by changing them to this:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:id="@+id/conversations_activity_menu_contacts"
        android:showAsAction="ifRoom|withText"
        android:title="@string/contacts" />
</menu>
Charles Madere
  • 6,642
  • 5
  • 35
  • 34
2

Hit the same issue, after an hour or so of playing the issue was tracked down to a single quote " ' ", being present in a resource . Removed the quote and the error went away.

arober11
  • 1,969
  • 18
  • 31
0

AAPT errors are sometimes caused by insufficient memory for eclipse to run in. See:

How to diagnose "Error executing aapt" error in Eclipse?

For the second part of your problem, see this:

Android Packaging Problem: resources.ap_ does not exist

Community
  • 1
  • 1
Anup Cowkur
  • 20,443
  • 6
  • 51
  • 84
  • I've already seen these answers but they didn't help. The system has plenty of free memory. I also updated to latest ADT and SDK versions but it didn't solve the error... – Patrick Dec 13 '12 at 18:36