0

Why do I get an aapt.exe has stopped working error when I put this code in my res/menu/menu.xml file? by the way, this comes directly from android developer website

XML:

<menu xmlns:android="http://schemas.android.com/apk/res/android" >
    <!-- Search, should appear as action button -->
    <item android:id="@+id/action_search"
          android:icon="@drawable/ic_action_search"
          android:title="@string/action_search"
          android:showAsAction="ifRoom" />
    <!-- Settings, should always be in the overflow -->
    <item android:id="@+id/action_settings"
          android:title="@string/action_settings"
          android:showAsAction="never" />
</menu>

I would like to have the search button always visible and I would like to have the settings button? I want 2 or more items in the xml, which I can't do.

Chad Bingham
  • 32,650
  • 19
  • 86
  • 115
Pheonix7
  • 2,131
  • 5
  • 21
  • 38
  • No. Don't worry. It happens, sometimes. Just clear the error and run the project. You will see this kind of joke many times. – Phantômaxx Jan 10 '14 at 15:57
  • 1
    i can't clean my project (and it doent auto generate the R.java file), and everytime i save i get the aapt.exe error... – Pheonix7 Jan 10 '14 at 15:58
  • hello. Do you have any other errors reported by aapt during compile? – iGio90 Jan 10 '14 at 15:59
  • So, you must have some problem in some xml files. Check them ALL, from Manifest to strings, whatever xml file you have. But also try a restart SOMETIMES it fixes – Phantômaxx Jan 10 '14 at 16:00

2 Answers2

0

I found the problem. I didn't have the icon. Unfortunately, eclipse and android doesn't have a clear and intuitive way of letting you know where the error is.

Chad Bingham
  • 32,650
  • 19
  • 86
  • 115
Pheonix7
  • 2,131
  • 5
  • 21
  • 38
0

I had the same issue when I modified the menu resource. The problem seems to occur when we remove action_settings item from the menu and the corresponding string resource. I re-introduced both the resources as below and the problem went away. in menu/main.xml:

 <menu xmlns:android="http://schemas.android.com/apk/res/android" >

  <item
    android:id="@+id/action_settings"
    android:orderInCategory="100"
    android:showAsAction="never"
    android:title="@string/action_settings"/>

 </menu>

in res/strings.xml

 <string name="action_settings">Settings</string>

If you dont need that item in menu, you could just add the tag:

  android:visible="false"

It appeares to be some kind of problem with the R.java file which contained a reference to action_settings even when it was removed, thereby causing the crash.

Nanda Ramesh
  • 131
  • 1
  • 1
  • 5