androidandroid-appcompat

java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/os/BuildCompat


I have updated the AppCompat libraries to 24.2.1 and the SDK to Android 7 in my Eclipse install. Since that, I'm not capable to run any of my apps. I appreciate if you can help a bit with that...

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

Solution

  • You are getting 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

    You are using Eclipse. Android Studio is a far simpler way to develop for Android if you manage to get the hang of it. For developers who have been using Eclipse, migrating to Studio is a nightmare for them. Eclipse is dead (My personal opinion).

    For your NoClassDefFoundError problem goto rebuild option under Project > Clean and then select the project you want to clean up .Then Restart your Eclipse and run again .

    Solutions

    Check your classpath contains that jar (AppCompat), if your classpath doesn't contain the jar then just add that class in your classpath.

    You should Use Android Studio instead of Eclipse . Read

    1. Support Library Features

    The Gradle build script dependency identifier for this library is as follows:

    com.android.support:appcompat-v7:24.2.1
    

    Then Clean-Rebuild-Restart IDE