I have a really strange problem. When I use ActionBarActivity after clicking on hardware menu button (device with Android 2.3) the app closes unexpectedly without any particular error. Logcat gives only:
W/KeyCharacterMap﹕ No keyboard for id 0
W/KeyCharacterMap﹕ Using default keymap: /system/usr/keychars/qwerty.kcm.bin
30-30/? I/DEBUG﹕ *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
03-19 15:54:48.612 30-30/? I/DEBUG﹕ Build fingerprint: 'generic/sdk/generic/:2.2/FRF91/43546:eng/test-keys'
03-19 15:54:48.612 30-30/? I/DEBUG﹕ pid: 785, tid: 785 >>> com.myapp <<<
03-19 15:54:48.612 30-30/? I/DEBUG﹕ signal 11 (SIGSEGV), fault addr 00000002
03-19 15:54:48.612 30-30/? I/DEBUG﹕ r0 00000000 r1 00000001 r2 00000001 r3 00000002
03-19 15:54:48.612 30-30/? I/DEBUG﹕ r4 bead28a4 r5 0000aa50 r6 001240a8 r7 0022b860
...
Code:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main, menu);
return false;
}
The issue appears if main.xml has any element.
I use 'com.android.support:appcompat-v7:19.0.+' as my gradle dependency.
All works fine when I use Activity.
Reported also at Android App crashes upon menu button click, this appears to be an issue with the latest 0.9.1 version of gradle and I can confirm that it kills apps on Froyo as well as Gingerbread. Read more about a similar problem here and another report here. The issue seems to be related to a new png processor. As mentioned by uchidev, the solution for now is to use gradle 0.9.0 by changing build.gradle.
An alternate suggestion to reverting: you can add android.aaptOptions.useAaptPngCruncher = true to build.gradle.
Update 3/28/14: This bug seems to have been fixed in Android Studio 0.5.3.
I encountered the just same problem today. Please change 'com.android.tools.build:gradle:0.9.+' of a build.gradle file into 'com.android.tools.build:gradle:0.9.0' and, sync project. I think that Gradle plugin version 0.9.1 is wrong.
来源:https://stackoverflow.com/questions/22509850/actionbaractivity-closes-after-pressing-hardware-menu-button-without-stack-trac