0

我正在使用ActionBarShelock并且有时会因为这个错误而无法找到如何处理它。

FATAL EXCEPTION: main
  java.lang.RuntimeException: Unable to start activity ComponentInfo{com.sps/com.sps.ui.activities.HomeActivity}: java.lang.NullPointerException
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
    at android.app.ActivityThread.access$600(ActivityThread.java:130)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:4745)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
    at dalvik.system.NativeStart.main(Native Method)
  Caused by: java.lang.NullPointerException
    at android.support.v4.app._ActionBarSherlockTrojanHorse.onCreatePanelMenu(_ActionBarSherlockTrojanHorse.java:52)
    at com.actionbarsherlock.ActionBarSherlock.callbackCreateOptionsMenu(ActionBarSherlock.java:556)
    at com.actionbarsherlock.internal.ActionBarSherlockNative.dispatchCreateOptionsMenu(ActionBarSherlockNative.java:60)
    at com.actionbarsherlock.app.SherlockFragmentActivity.onCreatePanelMenu(SherlockFragmentActivity.java:154)
    at com.android.internal.policy.impl.PhoneWindow.preparePanel(PhoneWindow.java:393)
    at com.android.internal.policy.impl.PhoneWindow.invalidatePanelMenu(PhoneWindow.java:747)
    at com.android.internal.policy.impl.PhoneWindow.restorePanelState(PhoneWindow.java:1677)
    at com.android.internal.policy.impl.PhoneWindow.restoreHierarchyState(PhoneWindow.java:1627)
    at android.app.Activity.onRestoreInstanceState(Activity.java:928)
    at android.app.Activity.performRestoreInstanceState(Activity.java:900)
    at android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1130)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2037)
    ... 11 more
4

1 回答 1

3

在 r7 支持库中,ActionBarSherlock 当前版本 (4.1.0) 所基于的版本,该类在将菜单事件分派到列表中包含的片段之前FragmentManager检查是否。这段代码被复制到 ActionBarSherlock 中,因为它使用自己的类型并进行自己的调度。mActive != nullmAddedMenuItem

在支持库的后续版本中,发现此检查不再代表是否mAdded已用列表实例化。提交464b6f3c将条件检查更改为mAdded != null.

自进行此修复以来,ActionBarSherlock 尚未发布。但是,它在提交69fe6fd的dev分支上进行了更新,以包含在下一个版本中。

于 2012-09-11T04:55:40.887 回答