使用ActionBarSherlock在onCreate中崩溃

时间:2014-02-09 19:05:12

标签: android actionbarsherlock

我的应用程序适用于大多数Android版本,但是当我在Android 2.2上运行它时,它在我创建SherlockActionBarDrawerToggle时崩溃:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    menu = (ListView) findViewById(R.id.left_drawer);
    ArrayAdapter<String> aa = new ArrayAdapter<String>(this,
            R.layout.item_menu, MENU);
    menu.setAdapter(aa);
    menu.setOnItemClickListener(this);

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow,
            GravityCompat.START);

    mActionBar = new ActionBarHelper();
    mActionBar.init();
    mActionBar.setTitle("CuantoComic+");
    mDrawerToggle = new SherlockActionBarDrawerToggle(this, mDrawerLayout,
            R.drawable.ic_drawer, R.string.drawer_open,
            R.string.drawer_close);

....

这是我的日志:

02-09 20:02:35.854: E/AndroidRuntime(541): FATAL EXCEPTION: main
02-09 20:02:35.854: E/AndroidRuntime(541): java.lang.ExceptionInInitializerError
02-09 20:02:35.854: E/AndroidRuntime(541):  at     com.sherlock.navigationdrawer.compat.SherlockActionBarDrawerToggle$ActionBarDrawerToggleImpl    Compat.getThemeUpIndicator(SherlockActionBarDrawerToggle.java:68)
02-09 20:02:35.854: E/AndroidRuntime(541):  at com.sherlock.navigationdrawer.compat.SherlockActionBarDrawerToggle.<init>(SherlockActionBarDrawerToggle.java:159)
02-09 20:02:35.854: E/AndroidRuntime(541):  at com.stormteam.cuantocomicplus.MainActivity.onCreate(MainActivity.java:64)
02-09 20:02:35.854: E/AndroidRuntime(541):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
02-09 20:02:35.854: E/AndroidRuntime(541):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
02-09 20:02:35.854: E/AndroidRuntime(541):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
02-09 20:02:35.854: E/AndroidRuntime(541):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
02-09 20:02:35.854: E/AndroidRuntime(541):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
02-09 20:02:35.854: E/AndroidRuntime(541):  at android.os.Handler.dispatchMessage(Handler.java:99)
02-09 20:02:35.854: E/AndroidRuntime(541):  at android.os.Looper.loop(Looper.java:123)
02-09 20:02:35.854: E/AndroidRuntime(541):  at android.app.ActivityThread.main(ActivityThread.java:4627)
02-09 20:02:35.854: E/AndroidRuntime(541):  at java.lang.reflect.Method.invokeNative(Native Method)
02-09 20:02:35.854: E/AndroidRuntime(541):  at java.lang.reflect.Method.invoke(Method.java:521)
02-09 20:02:35.854: E/AndroidRuntime(541):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
02-09 20:02:35.854: E/AndroidRuntime(541):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
02-09 20:02:35.854: E/AndroidRuntime(541):  at dalvik.system.NativeStart.main(Native Method)
02-09 20:02:35.854: E/AndroidRuntime(541): Caused by: java.lang.NoClassDefFoundError: com.sherlock.navigationdrawer.R$attr
02-09 20:02:35.854: E/AndroidRuntime(541):  at com.sherlock.navigationdrawer.compat.SherlockActionBarDrawerToggleCompat.<clinit>(SherlockActionBarDrawerToggleCompat.java:45)
02-09 20:02:35.854: E/AndroidRuntime(541):  ... 16 more

1 个答案:

答案 0 :(得分:0)

此类是否扩展了SherlockActivity,SherlockFragment或SherlockFragmentActivity?