2

最近我在我的 Android 应用中实现了 ActionBarSherlock。在 Google Apps 的开发者控制台的 Crash & ANR 报告中,有少量错误报告。我已经在模拟器 Android 2.2 到 4.2.2 中测试了该设备,在我的测试过程中出现了这样的错误,无论是在我的 Nexus 4 中还是在使用 Eclipse 运行的各种模拟器中。由于开发者控制台中没有给出用户消息,我无法识别导致此类错误的设备和 Android 版本。

java.lang.IllegalAccessError: tried to access field android.support.v4.app.Watson.mFragments from class android.support.v4.app.Watson
at android.support.v4.app.Watson.onCreatePanelMenu(Watson.java:51)
at com.actionbarsherlock.ActionBarSherlock.callbackCreateOptionsMenu(ActionBarSherlock.java:559)
at com.actionbarsherlock.internal.ActionBarSherlockCompat.preparePanel(ActionBarSherlockCompat.java:479)
at com.actionbarsherlock.internal.ActionBarSherlockCompat.dispatchInvalidateOptionsMenu(ActionBarSherlockCompat.java:272)
at com.actionbarsherlock.app.SherlockFragmentActivity.invalidateOptionsMenu(SherlockFragmentActivity.java:150)
at com.actionbarsherlock.app.SherlockFragmentActivity.supportInvalidateOptionsMenu(SherlockFragmentActivity.java:156)
at android.support.v4.app.Fragment.setHasOptionsMenu(Fragment.java:702)
at net.neobie.klse.MainMenuFragment.onCreateView(MainMenuFragment.java:45)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:505)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:709)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:692)
at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManagerImpl.java:1402)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:490)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1129)
at android.app.Activity.performStart(Activity.java:3885)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1595)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1638)
at android.app.ActivityThread.access$1500(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:928)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3647)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)

下面是我的 onCreateOptionsMenu。menu 和 inflater 参数均来自 com.actionbarsherlock.view

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {

    SubMenu subMenu1 = menu.addSubMenu("More");
    subMenu1.add(Menu.NONE, 1, 0, "Feedback").setIntent(new Intent(getActivity(), ContactActivity.class));
    subMenu1.add(Menu.NONE, 1, 0, "Backup & Restore").setIntent(new Intent(getActivity(), SyncActivity.class));
    subMenu1.add(Menu.NONE, 1, 0, "Settings").setIntent(new Intent(getActivity(), SettingsActivity.class));
    subMenu1.add(Menu.NONE, 1, 0, "About").setIntent(new Intent(getActivity(), AboutActivity.class));

    MenuItem subMenu1Item = subMenu1.getItem();
    subMenu1Item.setIcon(R.drawable.ic_menu_moreoverflow);
    subMenu1Item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);

我在 onCreateView 方法中的 View Inflater 之后有 setHasOptionsMenu:

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.main_menu, container, false);

        this.setHasOptionsMenu(true);

现在我需要更多关于上述错误的可能原因的信息,或者至少我如何重现上述错误以进行调试。谢谢。

4

0 回答 0