Home > database >  Can't set default animation to my action in nav_graph
Can't set default animation to my action in nav_graph

Time:08-03

I want to set deafault animation for my action in navigation component. But when I going to another fragment, app is crashing whith error:

java.lang.RuntimeException: Unknown animator name: accelerateDecelerateInterpolator
        at android.animation.AnimatorInflater.createAnimatorFromXml(AnimatorInflater.java:691)
        at android.animation.AnimatorInflater.createAnimatorFromXml(AnimatorInflater.java:642)
        at android.animation.AnimatorInflater.loadAnimator(AnimatorInflater.java:126)
        at android.animation.AnimatorInflater.loadAnimator(AnimatorInflater.java:106)
        at android.animation.AnimatorInflater.loadAnimator(AnimatorInflater.java:91)
        at androidx.fragment.app.FragmentAnim.loadAnimation(FragmentAnim.java:99)
        at androidx.fragment.app.DefaultSpecialEffectsController$AnimationInfo.getAnimation(DefaultSpecialEffectsController.java:877)
        at androidx.fragment.app.DefaultSpecialEffectsController.startAnimations(DefaultSpecialEffectsController.java:151)
        at androidx.fragment.app.DefaultSpecialEffectsController.executeOperations(DefaultSpecialEffectsController.java:123)
        at androidx.fragment.app.SpecialEffectsController.executePendingOperations(SpecialEffectsController.java:306)
        at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1903)
        at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1814)
        at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1751)
        at androidx.fragment.app.FragmentManager$5.run(FragmentManager.java:538)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:263)
        at android.app.ActivityThread.main(ActivityThread.java:8276)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:612)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1006)

In AnimatorInflater.java I found what many imports is red, so I think Android Studio cannot find these dependenscies. AnimatorInflater.java imports So I thing maybe some implimentations is wrong: https://github.com/Panicia/MVVMlearning1/blob/main/app/build.gradle

CodePudding user response:

That's because you use an Interpolator as the app:enterAnim and app:exitAnim. Interpolator "defines the rate of change of an animation", which means it's not an animation itself. Just update the app:enterAnim and app:exitAnim with some animations and it should solve the problem - examples here: Set animations.

  • Related