Android滑动菜单NoClassDef异常

Android滑动菜单NoClassDef异常,android,exception,slidingmenu,Android,Exception,Slidingmenu,我在论坛上看到过类似的问题,但这些问题无助于解决我的问题 我正在尝试使用以下代码使滑动菜单实现正常工作: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); try{ slidingM

我在论坛上看到过类似的问题,但这些问题无助于解决我的问题

我正在尝试使用以下代码使滑动菜单实现正常工作:

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

        try{
            slidingMenu = new SlidingMenu(this);
            slidingMenu.setMode(SlidingMenu.LEFT);
            slidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
            slidingMenu.setShadowWidthRes(R.dimen.slidingmenu_shadow_width);
            slidingMenu.setShadowDrawable(R.drawable.abs__ab_bottom_solid_dark_holo);
            slidingMenu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
            slidingMenu.setFadeDegree(0.35f);
            slidingMenu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
            slidingMenu.setMenu(R.layout.slidemenu);

//          if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
//              getActionBar().setDisplayHomeAsUpEnabled(true);
//          }
        }catch(Exception e){
            Toast.makeText(this, "SlideMenu malfunction!", Toast.LENGTH_LONG).show();
        }

    }
但我得到以下错误堆栈:

09-25 02:09:23.042: E/AndroidRuntime(7672): FATAL EXCEPTION: main
09-25 02:09:23.042: E/AndroidRuntime(7672): java.lang.NoClassDefFoundError: android.support.v4.view.ViewConfigurationCompat
09-25 02:09:23.042: E/AndroidRuntime(7672):     at com.jeremyfeinstein.slidingmenu.lib.CustomViewAbove.initCustomViewAbove(CustomViewAbove.java:167)
09-25 02:09:23.042: E/AndroidRuntime(7672):     at com.jeremyfeinstein.slidingmenu.lib.CustomViewAbove.<init>(CustomViewAbove.java:157)
09-25 02:09:23.042: E/AndroidRuntime(7672):     at com.jeremyfeinstein.slidingmenu.lib.CustomViewAbove.<init>(CustomViewAbove.java:152)
09-25 02:09:23.042: E/AndroidRuntime(7672):     at com.jeremyfeinstein.slidingmenu.lib.SlidingMenu.<init>(SlidingMenu.java:209)
09-25 02:09:23.042: E/AndroidRuntime(7672):     at com.jeremyfeinstein.slidingmenu.lib.SlidingMenu.<init>(SlidingMenu.java:192)
09-25 02:09:23.042: E/AndroidRuntime(7672):     at com.jeremyfeinstein.slidingmenu.lib.SlidingMenu.<init>(SlidingMenu.java:171)
09-25 02:09:23.042: E/AndroidRuntime(7672):     at com.icerge.revivaltimes.MainActivity.onCreate(MainActivity.java:19)
09-25 02:09:23.042: E/AndroidRuntime(7672):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1069)
09-25 02:09:23.042: E/AndroidRuntime(7672):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2751)
09-25 02:09:23.042: E/AndroidRuntime(7672):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2803)
09-25 02:09:23.042: E/AndroidRuntime(7672):     at android.app.ActivityThread.access$2300(ActivityThread.java:135)
09-25 02:09:23.042: E/AndroidRuntime(7672):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2136)
09-25 02:09:23.042: E/AndroidRuntime(7672):     at android.os.Handler.dispatchMessage(Handler.java:99)
09-25 02:09:23.042: E/AndroidRuntime(7672):     at android.os.Looper.loop(Looper.java:144)
09-25 02:09:23.042: E/AndroidRuntime(7672):     at android.app.ActivityThread.main(ActivityThread.java:4937)
09-25 02:09:23.042: E/AndroidRuntime(7672):     at java.lang.reflect.Method.invokeNative(Native Method)
09-25 02:09:23.042: E/AndroidRuntime(7672):     at java.lang.reflect.Method.invoke(Method.java:521)
09-25 02:09:23.042: E/AndroidRuntime(7672):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
09-25 02:09:23.042: E/AndroidRuntime(7672):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
09-25 02:09:23.042: E/AndroidRuntime(7672):     at dalvik.system.NativeStart.main(Native Method)

转到工作区中的
滑动菜单
库属性
Java构建路径
顺序和导出
选项卡>确保选中了
android-support-v4

清理你的项目。这应该是固定的

编辑:刚刚注意到你的清单中有ActionBar sherlock。在这种情况下,您需要对工作区中的actionbarsherlock库执行相同的步骤。然后您需要从滑动菜单库中删除android-support-v4。在actionbarsherlock中添加滑动菜单作为Android库依赖项。然后只将actionbarsherlock作为android库添加到应用程序中

您自己的项目应该在其自己的属性中引用ActionBarSherlock,如上所述
ActionbarSherlock
应该是libs文件夹中唯一具有
android-support-v4.jar
的项目


最后,清理-重建

转到工作区中的
滑动菜单
库属性
订购和导出
选项卡>确保选中了
android-support-v4

清理你的项目。这应该是固定的

编辑:刚刚注意到你的清单中有ActionBar sherlock。在这种情况下,您需要对工作区中的actionbarsherlock库执行相同的步骤。然后您需要从滑动菜单库中删除android-support-v4。在actionbarsherlock中添加滑动菜单作为Android库依赖项。然后只将actionbarsherlock作为android库添加到应用程序中

您自己的项目应该在其自己的属性中引用ActionBarSherlock,如上所述
ActionbarSherlock
应该是libs文件夹中唯一具有
android-support-v4.jar
的项目


最后,清理-重建

post activity\u main.xml post activity\u main.xml感谢您的回答。这有助于理解事物,我一直不折不扣地遵循它。但是,我得到了很多构建路径错误,我已经将这些错误粘贴到了我的原始问题中。我的滑动菜单库有一个红色的十字,而我的项目和actionbarsherlock库有红色感叹号。你能提供进一步的帮助吗?不用担心滑动菜单库和红十字会,它仍然可以工作。您只需要为您自己的项目和ActionbarSherlock转到Properties>Java Build Path>Libraries,删除上面有红色标记的内容。这应该可以解决问题。如果仍然没有,请从ActionbarSherlock中删除android-support-v4.jar,从您自己的机器上安装的adt中获取最新版本(我相信它将位于sdk\extras\android\support中),并将其复制到ActionbarSherlock的libs文件夹中。请确保在属性>Java构建路径>库中没有红色标记以获取答案。这有助于理解事物,我一直不折不扣地遵循它。但是,我得到了很多构建路径错误,我已经将这些错误粘贴到了我的原始问题中。我的滑动菜单库有一个红色的十字,而我的项目和actionbarsherlock库有红色感叹号。你能提供进一步的帮助吗?不用担心滑动菜单库和红十字会,它仍然可以工作。您只需要为您自己的项目和ActionbarSherlock转到Properties>Java Build Path>Libraries,删除上面有红色标记的内容。这应该可以解决问题。如果仍然没有,请从ActionbarSherlock中删除android-support-v4.jar,从您自己的机器上安装的adt中获取最新版本(我相信它将位于sdk\extras\android\support中),并将其复制到ActionbarSherlock的libs文件夹中。确保属性>Java构建路径>库中没有红色标记
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.icerge.revivaltimes"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="18" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/Theme.Sherlock" >
        <activity
            android:name="com.my.project.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>
MotionEventCompat cannot be resolved to a variable  CustomViewAbove.java    /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib    line 614    Java Problem
MotionEventCompat cannot be resolved    CustomViewAbove.java    /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib    line 600    Java Problem
MotionEventCompat cannot be resolved    CustomViewAbove.java    /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib    line 632    Java Problem
MotionEventCompat cannot be resolved    CustomViewAbove.java    /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib    line 631    Java Problem
MotionEventCompat cannot be resolved    CustomViewAbove.java    /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib    line 636    Java Problem
The constructor SlidingActivityHelper(SlidingFragmentActivity) is undefined SlidingFragmentActivity.java    /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib/app    line 21 Java Problem
MotionEventCompat cannot be resolved    CustomViewAbove.java    /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib    line 635    Java Problem
MotionEventCompat cannot be resolved to a variable  CustomViewAbove.java    /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib    line 681    Java Problem
MotionEventCompat cannot be resolved to a variable  CustomViewAbove.java    /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib    line 647    Java Problem
FragmentActivity cannot be resolved to a type   SlidingFragmentActivity.java    /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib/app    line 30 Java Problem
FragmentActivity cannot be resolved to a type   SlidingFragmentActivity.java    /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib/app    line 11 Java Problem
MotionEventCompat cannot be resolved    CustomViewAbove.java    /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib    line 691    Java Problem
MotionEventCompat cannot be resolved    CustomViewAbove.java    /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib    line 690    Java Problem
FragmentActivity cannot be resolved to a type   SlidingFragmentActivity.java    /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib/app    line 20 Java Problem
MotionEventCompat cannot be resolved    CustomViewAbove.java    /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib    line 705    Java Problem
FragmentActivity cannot be resolved to a type   SlidingFragmentActivity.java    /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib/app    line 50 Java Problem
MotionEventCompat cannot be resolved    CustomViewAbove.java    /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib    line 759    Java Problem
MotionEventCompat cannot be resolved    CustomViewAbove.java    /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib    line 760    Java Problem
FragmentActivity cannot be resolved to a type   SlidingFragmentActivity.java    /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib/app    line 39 Java Problem
MotionEventCompat cannot be resolved    CustomViewAbove.java    /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib    line 736    Java Problem
MotionEventCompat cannot be resolved to a variable  CustomViewAbove.java    /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib    line 758    Java Problem
MotionEventCompat cannot be resolved    CustomViewAbove.java    /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib    line 769    Java Problem
FragmentActivity cannot be resolved to a type   SlidingFragmentActivity.java    /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib/app    line 75 Java Problem
MotionEventCompat cannot be resolved    CustomViewAbove.java    /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib    line 780    Java Problem
MotionEventCompat cannot be resolved    CustomViewAbove.java    /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib    line 761    Java Problem
MotionEventCompat cannot be resolved to a variable  CustomViewAbove.java    /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib    line 764    Java Problem
MotionEventCompat cannot be resolved    CustomViewAbove.java    /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib    line 838    Java Problem
FragmentActivity cannot be resolved to a type   SlidingFragmentActivity.java    /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib/app    line 149    Java Problem
MotionEventCompat cannot be resolved    CustomViewAbove.java    /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib    line 843    Java Problem
MotionEventCompat cannot be resolved    CustomViewAbove.java    /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib    line 783    Java Problem
MotionEventCompat cannot be resolved    CustomViewAbove.java    /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib    line 837    Java Problem
KeyEventCompat cannot be resolved   CustomViewAbove.java    /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib    line 944    Java Problem
KeyEventCompat cannot be resolved   CustomViewAbove.java    /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib    line 946    Java Problem
MotionEventCompat cannot be resolved    CustomViewAbove.java    /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib    line 844    Java Problem