我在Eclipse安装中将AppCompat库更新为24.2.1,将SDK更新到Android 7.
从那以后,我无法运行任何应用程序.
如果你能帮助我,我感激不尽……
E/AndroidRuntime(17555): java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/os/BuildCompat;
E/AndroidRuntime(17555): at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:196)
E/AndroidRuntime(17555): at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:181)
E/AndroidRuntime(17555): at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:521)
E/AndroidRuntime(17555): at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:71)
E/AndroidRuntime(17555): at com.ryosoftware.calendareventsnotifier.MainActivity.onCreate(MainActivity.java:844)
E/AndroidRuntime(17555): at android.app.Activity.performCreate(Activity.java:5990)
E/AndroidRuntime(17555): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
E/AndroidRuntime(17555): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2311)
E/AndroidRuntime(17555): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2420)
E/AndroidRuntime(17555): at android.app.ActivityThread.access$900(ActivityThread.java:154)
E/AndroidRuntime(17555): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321)
E/AndroidRuntime(17555): at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime(17555): at android.os.Looper.loop(Looper.java:135)
E/AndroidRuntime(17555): at android.app.ActivityThread.main(ActivityThread.java:5294)
E/AndroidRuntime(17555): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(17555): at java.lang.reflect.Method.invoke(Method.java:372)
E/AndroidRuntime(17555): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
E/AndroidRuntime(17555): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699)
E/AndroidRuntime(17555): Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.os.BuildCompat" on path: DexPathList[[zip file "/data/app/com.ryosoftware.calendareventsnotifier-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
E/AndroidRuntime(17555): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
E/AndroidRuntime(17555): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
E/AndroidRuntime(17555): at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
E/AndroidRuntime(17555): ... 18 more
E/AndroidRuntime(17555): Suppressed: java.lang.ClassNotFoundException: android.support.v4.os.BuildCompat
E/AndroidRuntime(17555): at java.lang.Class.classForName(Native Method)
E/AndroidRuntime(17555): at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
E/AndroidRuntime(17555): at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
E/AndroidRuntime(17555): at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
E/AndroidRuntime(17555): ... 19 more
E/AndroidRuntime(17555): Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
最佳答案
你得到NoClassDefFoundError& ClassNotFoundException
NoClassDefFoundError in Java comes when Java Virtual Machine is not
able to find a particular class at runtime which was available at
compile time.
FYI
您正在使用Eclipse. Android Studio是一个更简单的Android开发方法,如果你能够掌握它的话.对于使用Eclipse的开发人员来说,迁移到Studio对他们来说是一场噩梦. Eclipse死了(我的个人意见).
对于NoClassDefFoundError问题,请在Project>下进行goto rebuild选项.清理然后选择要清理的项目.然后重新启动Eclipse并再次运行.
解决方案
Check your classpath contains that jar (AppCompat), if your classpath
doesn’t contain the jar then just add that class in your classpath.
您应该使用Android Studio而不是Eclipse.读
此库的Gradle构建脚本依赖项标识符如下:
com.android.support:appcompat-v7:24.2.1
然后Clean-Rebuild-Restart IDE