java.lang.IllegalAccessError:尝试访问字段

时间:2013-04-21 02:58:40

标签: android actionbarsherlock

最近我在Android App中实现了ActionBarSherlock。在崩溃& ANR在Google Apps的开发者控制台中报告,有一个小错误报告。 我已经在模拟器Android 2.2到4.2.2中测试了该设备,在我的测试期间抛出了这样的错误,无论是在我的Nexus 4还是用Eclipse运行的各种模拟器中。 由于Developer Console中没有给出用户消息,我无法识别导致此类错误的设备和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);

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

0 个答案:

没有答案