Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Eclipse Error executing aapt: return code 139

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?

like image 681
Patrick Avatar asked Dec 13 '12 18:12

Patrick


3 Answers

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.

like image 61
Nima G Avatar answered Oct 05 '22 10:10

Nima G


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

like image 20
Sensei Avatar answered Oct 05 '22 12:10

Sensei


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>
like image 25
Charles Madere Avatar answered Oct 05 '22 11:10

Charles Madere