Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/animation/AnimatorCompatHelper

After updating Android Studio to version 2.3. Every time I swipe my ViewPager I keep getting this error and the app crashes:

03-23 17:19:19.437 28523-28523/? E/AndroidRuntime: FATAL EXCEPTION: main    Process: com.irokotv.plus, PID: 28523    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.animateAdd(DefaultItemAnimator.java:218)        at android.support.v7.widget.SimpleItemAnimator.animateAppearance(SimpleItemAnimator.java:114)        at android.support.v7.widget.RecyclerView.animateAppearance(RecyclerView.java:3528)        at android.support.v7.widget.RecyclerView$4.processAppeared(RecyclerView.java:461)        at android.support.v7.widget.ViewInfoStore.process(ViewInfoStore.java:249)        at android.support.v7.widget.RecyclerView.dispatchLayoutStep3(RecyclerView.java:3385)        at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3135)        at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3568)        at android.view.View.layout(View.java:18793)        at android.view.ViewGroup.layout(ViewGroup.java:5952)        at android.support.v4.view.ViewPager.onLayout(ViewPager.java:1766)        at android.view.View.layout(View.java:18793)        at android.view.ViewGroup.layout(ViewGroup.java:5952)        at android.support.design.widget.HeaderScrollingViewBehavior.layoutChild(HeaderScrollingViewBehavior.java:131)        at android.support.design.widget.ViewOffsetBehavior.onLayoutChild(ViewOffsetBehavior.java:42)        at android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onLayoutChild(AppBarLayout.java:1364)        at android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:846)        at android.view.View.layout(View.java:18793)        at android.view.ViewGroup.layout(ViewGroup.java:5952)        at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)        at android.widget.FrameLayout.onLayout(FrameLayout.java:261)        at android.view.View.layout(View.java:18793)        at android.view.ViewGroup.layout(ViewGroup.java:5952)        at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1741)        at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)        at android.widget.LinearLayout.onLayout(LinearLayout.java:1494)        at android.view.View.layout(View.java:18793)        at android.view.ViewGroup.layout(ViewGroup.java:5952)        at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)        at android.widget.FrameLayout.onLayout(FrameLayout.java:261)        at android.view.View.layout(View.java:18793)        at android.view.ViewGroup.layout(ViewGroup.java:5952)        at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1741)        at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)        at android.widget.LinearLayout.onLayout(LinearLayout.java:1494)        at android.view.View.layout(View.java:18793)        at android.view.ViewGroup.layout(ViewGroup.java:5952)        at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)        at android.widget.FrameLayout.onLayout(FrameLayout.java:261)        at com.android.internal.policy.DecorView.onLayout(DecorView.java:818)        at android.view.View.layout(View.java:18793)        at android.view.ViewGroup.layout(ViewGroup.java:5952)        at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2615)        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2331)        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1490)        at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7027)        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:927)        at android.view.Choreographer.doCallbacks(Choreographer.java:702)        at android.view.Choreographer.doFrame(Choreographer.java:638)        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:913)        at android.os.Handler.handleCallback(Handler.java:751)        at android.os.Handler.dispatchMessage(Handler.java:95)        at android.os.Looper.loop(Looper.java:154)        at android.app.ActivityThread.main(ActivityThread.java:6688)        at java.lang.reflect.Method.invoke(Native Method)        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468) 

The app use to work well before the update. I already cleaned the project. Invalidate caches and run a gradle clean. No idea what else what I can do/try. My coworker can build the project and it works without any issue.

like image 893
tonyo.dev Avatar asked Mar 23 '17 21:03

tonyo.dev


2 Answers

write this code in your build.gradle file in the app folder

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'             }         }     } 

ref with this stackoverflow answer

I hope this will help you, happy coding

like image 182
Harshal Pathak Avatar answered Sep 22 '22 12:09

Harshal Pathak


I was using version 26.0.1 (on Android Studio 3.0 beta 2) support libraries had version 47 and I had the same issue. What worked for me is to remove/comment this line from all gradle files:

compile 'com.android.support:support-v4:26.0.1' 

Then added the following code from "Er Pathak Harshal" comment to the bottom of (Module: app and Module: Library) in build.gradle files:

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'             }         }     } } 

Please note if you have more than 1 build.gradle files i.e. (Module: library and Module: yourapp) you need to add that code in both files to make it work.

like image 21
Desolator Avatar answered Sep 25 '22 12:09

Desolator