java.lang.NoClassDefFoundError:解析失败:Landoll / support / graphics / drawable / VectorDrawableCompat Android on Lollipop

时间:2017-08-15 19:10:27

标签: java android android-studio

希望有人可以帮助我。在Lollipop版本上运行我的应用程序时出现此错误:

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

它在6.0&gt;上完美运行,你们有任何线索吗?已经在我的gradle文件中添加了vector-drawale依赖项。在这里搜索了类似的问题,但发现只有一个人在Eclipse上使用它,我正在使用Android Studio。在此先感谢!

我的gradle依赖项如下:

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'

}

2 个答案:

答案 0 :(得分:1)

我试图重现错误

这是导致错误的代码:

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'

这是解决错误的代码:

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'

答案 1 :(得分:0)

编译代码后,最终会得到程序中每个类的.class文件。这些二进制文件是Java解释执行程序的字节码。 NoClassDefFoundError指示负责动态加载类的类加载器(在本例中为java.net.URLClassLoader)无法找到您尝试使用的类的.class文件。

如果不存在所需的类(除非使用反射加载类),您的代码将无法编译,因此通常此异常意味着您的类路径不包含所需的类。请记住,类加载器(特别是java.net.URLClassLoader)将在类路径的每个条目中的文件夹a / b / c /中查找包a.b.c中的类。 NoClassDefFoundError还可以表明您错过了您编译的.jar文件的传递依赖项,并且您正在尝试使用。

例如,如果你有一个com.example.Foo类,那么在编译之后你就会得到一个类文件Foo.class。比如说你的工作目录是...... / project /。该类文件必须放在... / project / com / example中,您可以将类路径设置为... / project /.

旁注:我建议利用Java和JVM语言存在的神奇工具。现代IDE就像Eclipse和IDEA以及构建管理工具(如Maven或Gradle)将帮助您不必担心类路径(尽可能多)并专注于代码!也就是说,此链接说明了在命令行上执行时如何设置类路径。

如果缺少的类不是项目的内容,我创建了这个工具来查看给定类的开源工件。将类名粘贴到搜索框中,如果它是开源的,它会找到它。