Reputation: 682
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.
Upvotes: 34
Views: 29853
Reputation: 301
This Solved My Problem: add to dependencies:
implementation ("androidx.legacy:legacy-support-v4:1.0.0")
Then Sync.
Then add to Gradle.properties:
android.nonTransitiveRClass=true
android.defaults.buildfeatures.buildconfig=true
android.nonFinalResIds=true
android.enableJetifier=true
org.gradle.unsafe.configuration-cache=true
Then Invalidate Cashe
Upvotes: 0
Reputation: 2260
Use the latest support libraries. (Latest stable releases worked for me - i.e. currently upgrading from 27.1.1 or older to 28.0.0 fixes it.)
Upvotes: 1
Reputation: 117
Make sure in your build.gradle
file all implementations are of the same version.
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support:cardview-v7:26.1.0'
Upvotes: 0
Reputation: 485
i fixed the error updating version in Gradle app
implementation 'com.android.support:design:27.0.2'
implementation 'com.android.support:support-v4:27.0.2'
To
implementation 'com.android.support:design:27.1.1’
implementation 'com.android.support:support-v4:27.1.1’
Upvotes: 2
Reputation: 6795
I faced a same problem while integrating aviary sdk
, then solved downgrading things as below . .
compile 'com.android.support:appcompat-v7:25.4.0'
targetSdkVersion 25
compileSdkVersion 25
Upvotes: 0
Reputation: 396
Just generate an "APK" instead of instant run, and it will work perfectly.
Upvotes: 1
Reputation: 22759
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.
Upvotes: 14
Reputation: 17809
I also had the same problem. After hunting for a whole day found nothing. Then in the morning with fresh mind, i realised that my one of the custom library is using java 8 features and my app module gradle file does not enable it.
So i just added Following line in build.gradle(Modeule:app)
file to make it work:
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
I hope it helps others too.
Upvotes: 0
Reputation: 91
you can change support v7 lib version to 26.0.0-alpha1 shuch :
`compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
compile 'com.android.support:design:26.0.0-alpha1'
compile 'com.android.support:cardview-v7:26.0.0-alpha1'`
I hope this will help you
Upvotes: 9
Reputation: 787
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
Upvotes: 23
Reputation: 682
I was able to figure out what the issue was. Android studio updated the "Android support Repository"(located in sdk manager) to version 46 which included a bunch of Alpha support libs for Android O. I reverted back to version 25 and the issue was resolved. Apparently Android Studio 2.3 kept building against the Alpha support libraries causing a mismatch in dependencies which caused the app to crash.
Upvotes: 7