java – Android Eclipse Error executing aapt: return code 139-ThrowExceptions

Exception or error:

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?

How to solve:

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.

###

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

###

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>

###

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.

###

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

Leave a Reply

Your email address will not be published. Required fields are marked *