简体   繁体   中英

java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/graphics/drawable/VectorDrawableCompat Android on Lollipop

Hope someone can help me. I am having this error when running my app on Lollipop Versions:

Process: br.com.turbi.turbi, PID: 4279
                                                              java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/graphics/drawable/VectorDrawableCompat;
                                                                  at android.support.v7.widget.AppCompatDrawableManager$VdcInflateDelegate.createFromXmlInner(AppCompatDrawableManager.java:734)
                                                                  at android.support.v7.widget.AppCompatDrawableManager.loadDrawableFromDelegates(AppCompatDrawableManager.java:367)
                                                                  at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:197)
                                                                  at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:190)
                                                                  at android.support.v7.widget.AppCompatDrawableManager.checkVectorDrawableSetup(AppCompatDrawableManager.java:711)
                                                                  at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:195)
                                                                  at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:81)
                                                                  at android.support.v7.app.AppCompatDelegateImplBase.<init>(AppCompatDelegateImplBase.java:131)
                                                                  at android.support.v7.app.AppCompatDelegateImplV9.<init>(AppCompatDelegateImplV9.java:155)
                                                                  at android.support.v7.app.AppCompatDelegateImplV11.<init>(AppCompatDelegateImplV11.java:31)
                                                                  at android.support.v7.app.AppCompatDelegateImplV14.<init>(AppCompatDelegateImplV14.java:55)
                                                                  at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:205)
                                                                  at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:185)
                                                                  at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:519)
                                                                  at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:71)
                                                                  at br.com.turbi.turbi.SplashActivity.onCreate(SplashActivity.java:31)
                                                                  at android.app.Activity.performCreate(Activity.java:5990)
                                                                  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
                                                                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
                                                                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
                                                                  at android.app.ActivityThread.access$800(ActivityThread.java:151)
                                                                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
                                                                  at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                  at android.os.Looper.loop(Looper.java:135)
                                                                  at android.app.ActivityThread.main(ActivityThread.java:5254)
                                                                  at java.lang.reflect.Method.invoke(Native Method)
                                                                  at java.lang.reflect.Method.invoke(Method.java:372)
                                                                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
                                                                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
                                                               Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.graphics.drawable.VectorDrawableCompat" on path: DexPathList[[zip file "/data/app/br.com.turbi.turbi-2/base.apk"],nativeLibraryDirectories=[/data/app/br.com.turbi.turbi-2/lib/x86, /vendor/lib, /system/lib]]
                                                                  at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
                                                                  at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
                                                                  at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
                                                                  at android.support.v7.widget.AppCompatDrawableManager$VdcInflateDelegate.createFromXmlInner(AppCompatDrawableManager.java:734) 
                                                                  at android.support.v7.widget.AppCompatDrawableManager.loadDrawableFromDelegates(AppCompatDrawableManager.java:367) 
                                                                  at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:197) 
                                                                  at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:190) 
                                                                  at android.support.v7.widget.AppCompatDrawableManager.checkVectorDrawableSetup(AppCompatDrawableManager.java:711) 
                                                                  at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:195) 
                                                                  at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:81) 
                                                                  at android.support.v7.app.AppCompatDelegateImplBase.<init>(AppCompatDelegateImplBase.java:131) 
                                                                  at android.support.v7.app.AppCompatDelegateImplV9.<init>(AppCompatDelegateImplV9.java:155) 
                                                                  at android.support.v7.app.AppCompatDelegateImplV11.<init>(AppCompatDelegateImplV11.java:31) 
                                                                  at android.support.v7.app.AppCompatDelegateImplV14.<init>(AppCompatDelegateImplV14.java:55) 
                                                                  at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:205) 
                                                                  at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:185) 
                                                                  at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:519) 
                                                                  at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:71) 
                                                                  at br.com.turbi.turbi.SplashActivity.onCreate(SplashActivity.java:31) 
                                                                  at android.app.Activity.performCreate(Activity.java:5990) 
                                                                  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106) 
                                                                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278) 
                                                                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387) 
                                                                  at android.app.ActivityThread.access$800(ActivityThread.java:151) 
                                                                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) 
                                                                  at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                  at android.os.Looper.loop(Looper.java:135) 
                                                                  at android.app.ActivityThread.main(ActivityThread.java:5254) 
                                                                  at java.lang.reflect.Method.invoke(Native Method) 
                                                                  at java.lang.reflect.Method.invoke(Method.java:372) 
                                                                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) 
                                                                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 
                                                                Suppressed: java.lang.ClassNotFoundException: android.support.graphics.drawable.VectorDrawableCompat
                                                                  at java.lang.Class.classForName(Native Method)
                                                                  at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
                                                                  at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
                                                                  at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
                                                                        ... 30 more
                                                               Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

It runs perfectly on 6.0>, do you guys have any clues? Already added the vector-drawale dependence on my gradle file. Searched in here for similar problem but found only one guy having it on Eclipse, i am using Android Studio. Thanks in Advance!

My gradle dependencies below:

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:animated-vector-drawable:25.3.1'
compile 'com.android.support:customtabs:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:support-vector-drawable:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support:support-v13:25.3.1'
compile 'com.jakewharton:butterknife:8.5.1'
compile 'com.squareup.okhttp3:okhttp:3.6.0'
compile 'com.kyanogen.signatureview:signature-view:1.0'
compile 'io.card:android-sdk:5.5.0'
compile 'com.google.firebase:firebase-database:11.0.1'
compile 'com.google.firebase:firebase-auth:11.0.1'
compile 'com.facebook.android:facebook-android-sdk:4.25.0'
compile 'com.google.android.gms:play-services:11.0.1'
compile 'com.google.android.gms:play-services-location:11.0.1'
compile 'com.google.android.gms:play-services-maps:11.0.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.firebase:firebase-storage:11.0.1'
testCompile 'junit:junit:4.12'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
compile 'com.vicmikhailau:MaskedEditText:2.0.2'
compile 'com.google.firebase:firebase-crash:11.0.1'
compile 'com.google.firebase:firebase-messaging:11.0.1'
compile 'pl.droidsonroids.gif:android-gif-drawable:1.2.6'
compile('com.digits.sdk.android:digits:2.0.6@aar') {
    transitive = true;
}
compile 'com.airbnb.android:lottie:2.0.0-beta4'
compile 'com.felipecsl:gifimageview:2.1.0'
compile 'com.android.volley:volley:1.0.0'
compile 'com.squareup.okhttp3:okhttp:3.8.1'
compile 'com.koushikdutta.ion:ion:2.+'
/*** Glide ***/
compile 'com.github.bumptech.glide:glide:4.0.0-RC1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.0.0-RC1'
compile 'com.android.support:multidex:1.0.1'

}

I tried to reproduce the bug

here is the code which caused the bug :

compileSdkVersion 25
buildToolsVersion '25.0.0'
---------

compile 'com.android.support:recyclerview-v7:25.0.1'
compile 'com.android.support:appcompat-v7:25.0.1'
compile 'com.android.support:design:25.0.1'

here is the code which solved the bug :

compileSdkVersion 25
buildToolsVersion '25.0.0'
---------

compile 'com.android.support:recyclerview-v7:25.0.0'
compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.android.support:design:25.0.0'

After you compile your code, you end up with .class files for each class in your program. These binary files are the bytecode that Java interprets to execute your program. The NoClassDefFoundError indicates that the classloader (in this case java.net.URLClassLoader), which is responsible for dynamically loading classes, cannot find the .class file for the class that you're trying to use.

Your code wouldn't compile if the required classes weren't present (unless classes are loaded with reflection), so usually this exception means that your classpath doesn't include the required classes. Remember that the classloader (specifically java.net.URLClassLoader) will look for classes in package abc in folder a/b/c/ in each entry in your classpath. NoClassDefFoundError can also indicate that you're missing a transitive dependency of a .jar file that you've compiled against and you're trying to use.

For example, if you had a class com.example.Foo, after compiling you would have a class file Foo.class. Say for example your working directory is .../project/. That class file must be placed in .../project/com/example, and you would set your classpath to .../project/.

Side note: I would recommend taking advantage of the amazing tooling that exists for Java and JVM languages. Modern IDE's like Eclipse and IDEA and build management tools like Maven or Gradle will help you not have to worry about classpaths (as much) and focus on the code! That said, this link explains how to set the classpath when you execute on the command line.

If the class that's missing is not something from your project, I created this tool for looking through open source artifacts for a given class. Paste the classname in the search box, and it'll find it if it's open source.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM