h6ah4i / android-advancedrecyclerview

RecyclerView extension library which provides advanced features. (ex. Google's Inbox app like swiping, Play Music app like drag and drop sorting)
https://advancedrecyclerview.h6ah4i.com/
Apache License 2.0
5.32k stars 862 forks source link

AnimatorCompatHelper Class Not Found Exception using AppCompat 26.0.0 #396

Closed jordyamc closed 6 years ago

jordyamc commented 7 years ago

When using compat library 26.0.0 the app crash when doing Recyclerview Animations

java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/animation/AnimatorCompatHelper;
     at com.h6ah4i.android.widget.advrecyclerview.animator.impl.BaseItemAnimationManager.resetAnimation(BaseItemAnimationManager.java:161)
     at com.h6ah4i.android.widget.advrecyclerview.animator.RefactoredDefaultItemAnimator$DefaultItemMoveAnimationManager.addPendingAnimation(RefactoredDefaultItemAnimator.java:312)
     at com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator.animateMove(GeneralItemAnimator.java:88)
     at android.support.v7.widget.SimpleItemAnimator.animatePersistence(SimpleItemAnimator.java:140)
     at android.support.v7.widget.RecyclerView$4.processPersistent(RecyclerView.java:543)
     at android.support.v7.widget.ViewInfoStore.process(ViewInfoStore.java:239)
     at android.support.v7.widget.RecyclerView.dispatchLayoutStep3(RecyclerView.java:3761)
     at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3419)
     at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3960)
h6ah4i commented 7 years ago

Hi, thanks for the report. I guess there are a lot of more incompatibilities exist because the support library v26 has changed its min SDK to API level 14. Also, I am going to change the min SDK level of this library when after non-beta version of support library v26 is released.

jordyamc commented 7 years ago

I made a pull request with a temporally fix using appcompat 25.3.1

jordyamc commented 7 years ago

Also i use Appcompat 26.0.0-beta2 in my app and i have no problems with Drag/Drop, Swipe, and Expand/Collapse using my fix :D

arkon commented 7 years ago

I'm seeing this issue with the stable release of AppCompat 26.0.0 too.

guidedways commented 7 years ago

Would be good to have this fix out please

iUmarov commented 7 years ago

I have got the same crash with stable release of Support Library 26.0.0

h6ah4i commented 7 years ago

Hi, guys. Sorry for the inconvenience πŸ™‡

I am going to start working for the new support libraries v26.0.0. Hopefully, I can manage all features work well with the new libraries soon...

h6ah4i commented 7 years ago

I've just pushed a new branch which bumps support libraries to v26. I am now working on this branch and its still a pre-stable version.


If you want to try it out now, please add the following jitpack configuration to build.gradle.

repositories {
    maven { url "https://jitpack.io" }
}
dependencies {
    compile 'com.github.h6ah4i:android-advancedrecyclerview:feature~support_libraries_v26-SNAPSHOT'
}
huteri commented 7 years ago

@h6ah4i tried it, and still crashing

FATAL EXCEPTION: main
Process: com.huteri.monas, PID: 13689
java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/animation/AnimatorCompatHelper;
    at com.h6ah4i.android.widget.advrecyclerview.animator.impl.BaseItemAnimationManager.resetAnimation(BaseItemAnimationManager.java:161)
    at com.h6ah4i.android.widget.advrecyclerview.animator.RefactoredDefaultItemAnimator$DefaultItemChangeAnimationManager.addPendingAnimation(RefactoredDefaultItemAnimator.java:220)
    at com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator.animateChange(GeneralItemAnimator.java:111)
    at android.support.v7.widget.SimpleItemAnimator.animateChange(SimpleItemAnimator.java:163)
    at android.support.v7.widget.RecyclerView.animateChange(RecyclerView.java:3954)
    at android.support.v7.widget.RecyclerView.dispatchLayoutStep3(RecyclerView.java:3753)
    at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3421)
    at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3962)
    at android.view.View.layout(View.java:17523)
    at android.view.ViewGroup.layout(ViewGroup.java:5612)
    at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1079)
    at android.view.View.layout(View.java:17523)
    at android.view.ViewGroup.layout(ViewGroup.java:5612)
    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
    at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
    at android.view.View.layout(View.java:17523)
    at android.view.ViewGroup.layout(ViewGroup.java:5612)
    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
    at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
    at android.view.View.layout(View.java:17523)
    at android.view.ViewGroup.layout(ViewGroup.java:5612)
    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:17523)
    at android.view.ViewGroup.layout(ViewGroup.java:5612)
    at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:1172)
    at android.view.View.layout(View.java:17523)
    at android.view.ViewGroup.layout(ViewGroup.java:5612)
    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
    at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
    at android.view.View.layout(View.java:17523)
    at android.view.ViewGroup.layout(ViewGroup.java:5612)
    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
    at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
    at android.view.View.layout(View.java:17523)
    at android.view.ViewGroup.layout(ViewGroup.java:5612)
    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
    at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
    at android.view.View.layout(View.java:17523)
    at android.view.ViewGroup.layout(ViewGroup.java:5612)
    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
    at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
    at android.view.View.layout(View.java:17523)
    at android.view.ViewGroup.layout(ViewGroup.java:5612)
    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:724)
    at android.view.View.layout(View.java:17523)
    at android.view.ViewGroup.layout(ViewGroup.java:5612)
    at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2342)
    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2069)
    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1246)
    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6301)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:871)
    at android.view.Choreographer.doCallbacks(Choreographer.java:683)
    at android.view.Choreographer.doFrame(Choreographer.java:619)
    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:857)
    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:6077)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
 Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.animation.AnimatorCompatHelper" on path: DexPathList[[zip file "/data/app/com.huteri.monas-1/base.apk", zip file "/data/app/com.huteri.monas-1/split_lib_dependencies_apk.apk", zip file "/data/app/com.huteri.monas-1/split_lib_slice_0_apk.apk", zip file "/data/app/com.huteri.monas-1/split_lib_slice_1_apk.apk", zip file "/data/app/com.huteri.monas-1/split_lib_slice_2_apk.apk", zip file "/data/app/com.huteri.monas-1/split_lib_slice_3_apk.apk", zip file "/data/app/com.huteri.monas-1/split_lib_slice_4_apk.apk", zip file "/data/app/com.huteri.monas-1/split_lib_slice_5_apk.apk", zip file "/data/app/com.huteri.monas-1/split_lib_slice_6_apk.apk", zip file "/data/app/com.huteri.monas-1/split_lib_slice_7_apk.apk", zip file "/data/app/com.huteri.monas-1/split_lib_slice_8_apk.apk", zip file "/data/app/com.huteri.monas-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.huteri.monas-1/lib/x86, /system/lib, /vendor/lib]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        ... 65 more

and yes, I have cleaned and reinstalled,

screen shot 2017-08-09 at 1 27 48 pm

EDIT

Solved with

compile 'com.github.h6ah4i:android-advancedrecyclerview:feature~support_libraries_v26-SNAPSHOT'
h6ah4i commented 7 years ago

@huteri Thanks for your clarification. I forgot to change the commit ID πŸ˜“

guidedways commented 7 years ago

Any updates on this? Android O just got officially released by the way yesterday, which means we're still waiting for an official fix on the main branch.

Devofure commented 7 years ago

Please, give us more information about when this library will be updated, Thank you.

iUmarov commented 7 years ago

I am about to publish my app in which I used this library. So, I would like to know whether I should wait for its stable release or pre-stable version (feature~support_libraries_v26-SNAPSHOT) is also fine.

Twinsen81 commented 7 years ago

This solution worked for me: https://stackoverflow.com/questions/43320496/noclassdeffounderror-android-support-v4-animation-animatorcompathelper

Added to the bottom of the build.gradle (Module:app):

configurations.all { resolutionStrategy.eachDependency { DependencyResolveDetails details -> def requested = details.requested if (requested.group == 'com.android.support') { if (!requested.name.startsWith("multidex")) { details.useVersion '25.4.0' } } } }

SUKI-Huang commented 7 years ago
compile 'com.github.h6ah4i:android-advancedrecyclerview:feature~support_libraries_v26-SNAPSHOT'

does not available now ? I got an error this morning

Error:Could not find com.github.h6ah4i:android-advancedrecyclerview:feature~support_libraries_v26-SNAPSHOT.
Required by:
    project :TEST
    Search in build.gradle files
FredDevAxes commented 7 years ago

Same here! The snapshot version with support library 26 does not seem to be available anymore. :/

olidroide commented 7 years ago

@FredDev06 @SUKI-Huang I'm using develop branch as workaround:

compile 'com.github.h6ah4i:android-advancedrecyclerview:develop-SNAPSHOT'

fmeneuhe commented 7 years ago

Has this issue of NoClassDefFoundError been fixed?

fdonzello commented 7 years ago

nope.. still there in develop-SNAPSHOT

AXwjg commented 7 years ago

The solution is to add the following code block to your build.gradle: configurations.all { resolutionStrategy.eachDependency { DependencyResolveDetails details -> def requested = details.requested if (requested.group == 'com.android.support') { if (!requested.name.startsWith("multidex")) { details.useVersion '24.1.0' } } } }

devjta commented 7 years ago

wrong project ;-)

tdtran commented 7 years ago

FWIW I use the snapshot version in production and it works perfectly well for users of my apps

devjta commented 7 years ago

Yeah, was barking at the wrong tree :D Found the error/cultrip for it..

But if you have to wait for external programs + HAVE to use the Android 8.0/Oreo SDK, just create the class with the HoneyCombImplementation:

Create class: android.support.v4.animation.AnimatorCompatHelper

public class AnimatorCompatHelper { private static TimeInterpolator mDefaultInterpolator; public static void clearInterpolator(View view){ if(view != null){ if (mDefaultInterpolator == null) { mDefaultInterpolator = new ValueAnimator().getInterpolator(); } view.animate().setInterpolator(mDefaultInterpolator); } } }

svenoaks commented 7 years ago

Creating the AnimatorCompatHelper class seems to work but not sure if totally safe. compile 'com.github.h6ah4i:android-advancedrecyclerview:develop-SNAPSHOT' has weird animation when item is dragged to new position that wasn't present in older.

SUKI-Huang commented 7 years ago

I got same issue with @svenoaks

devjta commented 6 years ago

Well all I did was looking at the sources of AnimatorCompatHelper and replaced its behavior. Original code: https://android.googlesource.com/platform/frameworks/support/+/e1e957f/v4/java/android/support/v4/animation/AnimatorCompatHelper.java And the impl of the animator: https://github.com/phhusson/SafetyNet/blob/master/android/support/v4/animation/HoneycombMr1AnimatorCompatProvider.java

h6ah4i replaced it the same way I did it..

I used that trick in that project: https://github.com/muditsen/multilevelrecyclerview/pull/5 and the recyclerview works fine. But if you have problems, maybe the problem could also be there.. So it would be really nice to know, how it was changed in the snapshot.

devjta commented 6 years ago

If you create the AnimatorCompatHelper class, you dont need the develop-branch!! The devleop-branch got rid of the class and instead uses this here (decompiled from the develop-lib)

protected void resetAnimation(RecyclerView.ViewHolder holder) {
    if (sDefaultInterpolator == null) {
        sDefaultInterpolator = new ValueAnimator().getInterpolator();
    }
    holder.itemView.animate().setInterpolator(sDefaultInterpolator);
    endAnimation(holder);
}

VS https://github.com/h6ah4i/android-advancedrecyclerview/blob/master/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/impl/BaseItemAnimationManager.java

Which is kinda the same, you will see in the HoneycombMr1AnimatorCompatProvider.java or at my post 2 days ago.

So again with the develop version, you dont need to create the CompatHelper class. You can use the stable version and add the CompatHelper class.

But both things uses the same methods.. So if the animations are not working, I cannot help you at all.. Just try the NOT-develop version/Stable version with the AnimatorCompatHelper and see if it works..

svenoaks commented 6 years ago

@devjta thanks for your help I don't have problems with your class and I am using the stable branch, I'm just worried that there might be other incompatibilities with library 26 besides this obvious one if it is used in production.

devjta commented 6 years ago

I am developing for a week with the 26sdk + support (v4 and v7) now and everything looks quite good.

There were some changes for Notifiation-stuff (you need a channel now) and background-services are limited now. But these change just happens on Android 8 devices..

h6ah4i commented 6 years ago

@svenoaks, @devjta, @SUKI-Huang, @tdtran, @AXwjg, @fdonzello

Hi all, sorry for the very late response πŸ™‡

I have just released v0.11.0 today and it includes the fix of this issue, so I am going to close this issue within a few days.


Creating the AnimatorCompatHelper class seems to work but not sure if totally safe. compile 'com.github.h6ah4i:android-advancedrecyclerview:develop-SNAPSHOT' has weird animation when item is dragged to new position that wasn't present in older. https://github.com/h6ah4i/android-advancedrecyclerview/issues/425

I am afraid that this might be a regression of the latest release.

I hope this issue would be solved by implementing the new onItemDragStarted() / onItemDragFinished() methods. Please read the following migration guide for more detials. (If you still see the issue with v0.11.0 , please create a new issue report.) Thanks.

guidedways commented 6 years ago

He's alive!!! Thanks man.

yimiIO commented 6 years ago

the solutation all use old version , @h6ah4i how u fix the problem without AnimatorCompatHelper? I can`t find where I use it , select none result in my project , so can u tell me how to find where I use it then fix it.

ajit-sharma commented 6 years ago

Even after shifting to 25.3.1 it causing a crash. No previously mentioned tricks working. Please help.

devjta commented 6 years ago

The solution many use, is what I posted at 25th October.. Just create the class and implement the method like it was in Android sdk. Or the project-owner remove any use of the AnimatorCompatHelper (also includes, etc.) and uses his own animation or copy the impl from Android.

swapnilbhai90 commented 6 years ago

I am using buildtoolVersion 26.0.2 and targetSdkVersion 26.0.2 . Using library Expandablelayout which is using AnimatorCompatHelper. I crashing saying java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/animation/AnimatorCompatHelper;

Please help me out with this...can't remove this lib