Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
611 views
in Technique[技术] by (71.8m points)

android - ActionBarActivity closes after pressing hardware menu button. Without stack trace

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...