Landroid/support/v4/animation/AnimatorCompatHelper
java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/animation/AnimatorCompatHelper;
at android.support.v7.widget.DefaultItemAnimator.resetAnimation(DefaultItemAnimator.java:515)at android.support.v7.widget.DefaultItemAnimator.animateMove(DefaultItemAnimator.java:255)
at android.support.v7.widget.DefaultItemAnimator.animateChange(DefaultItemAnimator.java:317)
at android.support.v7.widget.SimpleItemAnimator.animateChange(SimpleItemAnimator.java:149)
at android.support.v7.widget.RecyclerView.animateChange(RecyclerView.java:3836)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep3(RecyclerView.java:3643)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3323)
at android.support.v7.widget.RecyclerView.consumePendingUpdateOperatio(RecyclerView.java:1637)at android.support.v7.widget.RecyclerView$1.run(RecyclerView.java:343)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:804)
at android.view.Choreographer.doCallbacks(Choreographer.java:607)
at android.view.Choreographer.doFrame(Choreographer.java:575)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:790)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:224)
at android.app.ActivityThread.main(ActivityThread.java:5929)
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:1113)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:879)
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.animation.AnimatorCompatHelper" on path: DexPathList[[zip file "/data/app/com.shtoone.smarthelmet-1/base.apk", zip file "/data/app/com.shtoone.smarthelmet-1/split_lib_dependencies_apk.apk", zip file "/data/app/com.shtoone.smarthelmet-1/split_lib_slice_0_apk.apk", zip file "/data/app/com.shtoone.smarthelmet-1/split_lib_slice_1_apk.apk", zip file "/data/app/com.shtoone.smarthelmet-1/split_lib_slice_2_apk.apk", zip file "/data/app/com.shtoone.smarthelmet-1/split_lib_slice_3_apk.apk", zip file "/data/app/com.shtoone.smarthelmet-1/split_lib_slice_4_apk.apk", zip file "/data/app/com.shtoone.smarthelmet-1/split_lib_slice_5_apk.apk", zip file "/data/app/com.shtoone.smarthelmet-1/split_lib_slice_6_apk.apk", zip file "/data/app/com.shtoone.smarthelmet-1/split_lib_slice_7_apk.apk", zip file "/data/app/com.shtoone.smarthelmet-1/split_lib_slice_8_apk.apk", zip file "/data/app/com.shtoone.smarthelmet-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.shtoone.smarthelmet-1/lib/arm64, /vendor/lib64, /system/lib64]]
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.DefaultItemAnimator.resetAnimation(DefaultItemAnimator.java:515)
at android.support.v7.widget.DefaultItemAnimator.animateMove(DefaultItemAnimator.java:255)
at android.support.v7.widget.DefaultItemAnimator.animateChange(DefaultItemAnimator.java:317)
at android.support.v7.widget.SimpleItemAnimator.animateChange(SimpleItemAnimator.java:149)
at android.support.v7.widget.RecyclerView.animateChange(RecyclerView.java:3836)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep3(RecyclerView.java:3643)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3323)
at android.support.v7.widget.RecyclerView.consumePendingUpdateOperations(RecyclerView.java:1637)
at android.support.v7.widget.RecyclerView$1.run(RecyclerView.java:343)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:804)
at android.view.Choreographer.doCallbacks(Choreographer.java:607)
at android.view.Choreographer.doFrame(Choreographer.java:575)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:790)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:224)
at android.app.ActivityThread.main(ActivityThread.java:5929)
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:1113)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:879)
Suppressed: java.lang.ClassNotFoundException:
android.support.v4.animation.AnimatorCompatHelper
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)
... 22 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
01-31 08:08:39.897 375-5748/? E/NuPlayer: onScanSources
根据CauseBy可知,异常的原因是找不到类导致的。根据查到的资料分析:项目中存在多个support libraries Gradle编译的时候回优先采用最新版本,而不是你希望采用的版本(翻译的很勉强,英语不错的同学可以直接点击参考资料中的链接查看原文)。
我的理解是:我的项目中可能存在多个V4包,而编译的时候不知道用哪个。干脆就都不用,所以就出现了找不到类的异常。这是很正常的现象,在引用第三方库时。三方库会自带v4包(用到v4包中的一些函数),三方库并不能确定其应用环境一定存在v4包。
解决方案:在gradle文件中添加下方代码,强制指定版本。
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
if (!requested.name.startsWith("multidex")) {
details.useVersion '25.3.0'
}
}
}
}