问题
I read on the CommonsWare blog that it's a smart idea to update appcompat-v7 to the newest version before the roll out of Android 6.0 so I just went ahead and tried to do that with my project in Eclipse. After updating the library (I simply removed the previous version and added the new one with resources), my (previously ActionBarActivity) AppCompatActivity does not start (the app crashes). This is the LogCat content:
08-20 02:55:58.417: I/art(28031): Rejecting re-init on previously-failed class java.lang.Class<android.support.v7.app.AppCompatDelegateImplV7>
08-20 02:55:58.418: I/art(28031): Rejecting re-init on previously-failed class java.lang.Class<android.support.v7.app.AppCompatDelegateImplV7>
08-20 02:55:58.419: I/art(28031): Rejecting re-init on previously-failed class java.lang.Class<android.support.v7.app.AppCompatDelegateImplV11>
08-20 02:55:58.419: I/art(28031): Rejecting re-init on previously-failed class java.lang.Class<android.support.v7.app.AppCompatDelegateImplV11>
08-20 02:55:58.419: I/art(28031): Rejecting re-init on previously-failed class java.lang.Class<android.support.v7.app.AppCompatDelegateImplV14>
08-20 02:55:58.420: I/art(28031): Rejecting re-init on previously-failed class java.lang.Class<android.support.v7.app.AppCompatDelegateImplV14>
08-20 02:55:58.420: I/art(28031): Rejecting re-init on previously-failed class java.lang.Class<android.support.v7.app.AppCompatDelegateImplV23>
08-20 02:55:58.420: I/art(28031): Rejecting re-init on previously-failed class java.lang.Class<android.support.v7.app.AppCompatDelegateImplV23>
08-20 02:55:58.421: I/art(28031): Rejecting re-init on previously-failed class java.lang.Class<android.support.v7.app.AppCompatDelegateImplV14>
08-20 02:55:58.421: I/art(28031): Rejecting re-init on previously-failed class java.lang.Class<android.support.v7.app.AppCompatDelegateImplV11>
08-20 02:55:58.421: I/art(28031): Rejecting re-init on previously-failed class java.lang.Class<android.support.v7.app.AppCompatDelegateImplV7>
08-20 02:55:58.421: I/art(28031): Rejecting re-init on previously-failed class java.lang.Class<android.support.v7.app.AppCompatDelegateImplV23>
08-20 02:55:58.421: D/AndroidRuntime(28031): Shutting down VM
08-20 02:55:58.422: E/AndroidRuntime(28031): FATAL EXCEPTION: main
08-20 02:55:58.422: E/AndroidRuntime(28031): Process: com.threeeplusplus.karkoona, PID: 28031
08-20 02:55:58.422: E/AndroidRuntime(28031): java.lang.NoClassDefFoundError: android.support.v7.app.AppCompatDelegateImplV23
08-20 02:55:58.422: E/AndroidRuntime(28031): at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:133)
08-20 02:55:58.422: E/AndroidRuntime(28031): at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:117)
08-20 02:55:58.422: E/AndroidRuntime(28031): at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:456)
08-20 02:55:58.422: E/AndroidRuntime(28031): at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:59)
08-20 02:55:58.422: E/AndroidRuntime(28031): at com.threeeplusplus.karkoona.activities.CentralNavActivity.onCreate(CentralNavActivity.java:154)
08-20 02:55:58.422: E/AndroidRuntime(28031): at android.app.Activity.performCreate(Activity.java:6237)
08-20 02:55:58.422: E/AndroidRuntime(28031): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
08-20 02:55:58.422: E/AndroidRuntime(28031): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
08-20 02:55:58.422: E/AndroidRuntime(28031): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
08-20 02:55:58.422: E/AndroidRuntime(28031): at android.app.ActivityThread.-wrap11(ActivityThread.java)
08-20 02:55:58.422: E/AndroidRuntime(28031): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
08-20 02:55:58.422: E/AndroidRuntime(28031): at android.os.Handler.dispatchMessage(Handler.java:102)
08-20 02:55:58.422: E/AndroidRuntime(28031): at android.os.Looper.loop(Looper.java:148)
08-20 02:55:58.422: E/AndroidRuntime(28031): at android.app.ActivityThread.main(ActivityThread.java:5417)
08-20 02:55:58.422: E/AndroidRuntime(28031): at java.lang.reflect.Method.invoke(Native Method)
08-20 02:55:58.422: E/AndroidRuntime(28031): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
08-20 02:55:58.422: E/AndroidRuntime(28031): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
I've been trying to fix this for hours but nothing works! I cleaned, re-cleaned, removed the library, re-added, checked the .jar files for the contained class files and sure enough there's an AppCompatDelegateImplV23 there etc. Nothing.
Any ideas?
回答1:
After trying everything I could think of, I ended up removing the library from the workspace, the android-support-v4.jar and android-support-v7-appcompat.jar from my project's /bin folder and I also went to Properties -> Android and in the Libraries section removed android-support-v7-appcompat.
I also removed everything related to the support library in Java Build Path -> Libraries and Java Build Path -> Order and Export.
I then re-imported the library and it the error went away. The app now works but the v23 appcompat library is kind of messed up (for one, the Action Mode does not overlay the support Toolbar, it now appears over it - ie between the status bar and the toolbar)
回答2:
I had exactly same error and came accross with following solution:
Close your actual workspace with your DEVELOPMENT project
Create new workspace
- Create new Android TEST project. This will automatically create appcompat_v7 with Android last updated version.
- Go to your DEVELOPMENT project workspace PATH, (not into Eclipse, The workspace directory)
- Delete appcompat_v7
- Go to your Android TEST project workspace PATH
- Copy this appcompat_v7
- Paste into your DEVELOPMENT project workspace PATH
- Now Open Eclipse with your DEVELOPMENT project workspace
FIXED
来源:https://stackoverflow.com/questions/32107568/updated-appcompat-v7-to-the-newest-version-get-noclassdeffound-for-appcompatdel