2

Ready for a crazy one (android par for the course).

Only with Ice Cream Sandwich, somewhere in onPreparedOptionsMenu (or onCreateOptionsMenu) getting this nasty crash below.

My code? Simple. I've tried the commons apps, and a brand new app which all WORK,however, my app is doing something that ICS doesn't like, but I can't figure out what. The code is so simple:

 @Override
    public boolean onPrepareOptionsMenu(final Menu menu){
    // comment menu.add out and no exception
        menu.add(0,0,0,"Add");
        return super.onPrepareOptionsMenu(menu);


    }

More exciting/fun. IF I rotate the device and back again (or just rotate), IT WORKS. Something in the intial setup/launch of the app appears to be wrong. I've tested this in every emulator up to 4.0.3 and they ALL WORK , except 4.x.

/AndroidRuntime( 2406): FATAL EXCEPTION: main
E/AndroidRuntime( 2406): android.content.res.Resources$NotFoundException: Resource ID #0x1090045
E/AndroidRuntime( 2406):    at android.content.res.Resources.getValue(Resources.java:1019)
E/AndroidRuntime( 2406):    at android.content.res.Resources.loadXmlResourceParser(Resources.java:2107)
E/AndroidRuntime( 2406):    at android.content.res.Resources.getLayout(Resources.java:858)
E/AndroidRuntime( 2406):    at android.view.LayoutInflater.inflate(LayoutInflater.java:394)
E/AndroidRuntime( 2406):    at com.android.internal.view.menu.BaseMenuPresenter.getMenuView(BaseMenuPresenter.java:70)
E/AndroidRuntime( 2406):    at com.android.internal.policy.impl.PhoneWindow$PanelFeatureState.getIconMenuView(PhoneWindow.java:3320)
E/AndroidRuntime( 2406):    at com.android.internal.policy.impl.PhoneWindow.initializePanelContent(PhoneWindow.java:1096)
E/AndroidRuntime( 2406):    at com.android.internal.policy.impl.PhoneWindow.openPanel(PhoneWindow.java:559)
E/AndroidRuntime( 2406):    at com.android.internal.policy.impl.PhoneWindow.onKeyUpPanel(PhoneWindow.java:817)
E/AndroidRuntime( 2406):    at com.android.internal.policy.impl.PhoneWindow.onKeyUp(PhoneWindow.java:1486)
E/AndroidRuntime( 2406):    at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1813)
E/AndroidRuntime( 2406):    at android.view.ViewRootImpl.deliverKeyEventPostIme(ViewRootImpl.java:3327)
E/AndroidRuntime( 2406):    at android.view.ViewRootImpl.handleFinishedEvent(ViewRootImpl.java:3300)
E/AndroidRuntime( 2406):    at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2460)
E/AndroidRuntime( 2406):    at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 2406):    at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime( 2406):    at android.app.ActivityThread.main(ActivityThread.java:4424)
E/AndroidRuntime( 2406):    at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 2406):    at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime( 2406):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
E/AndroidRuntime( 2406):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
E/AndroidRuntime( 2406):    at dalvik.system.NativeStart.main(Native Method)
Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
aloharich
  • 19
  • 5
  • 1
    I can confirm I experience the same bug. ICS only. Also, rotating before clicking the menu makes the menu appear. The (exactly same) menu works in other activities, just in one it does not: This one extends from ListActivity, the others do not. Is yours also a ListActivity? – Bachi Apr 11 '12 at 16:45
  • I filed a bug at http://code.google.com/p/android/issues/detail?id=28807 - did you find a solution yet? – Bachi Apr 13 '12 at 22:00
  • Seeing the same thing with a `FragmentActivity` that hosts a `ListFragment`: only on Android 4.0.3. – Femi Apr 18 '12 at 15:28

0 Answers0