Exception: Unknown animator name: propertyValuesHolder on Android 5/5.1

Issue

This Content is from Stack Overflow. Question asked by Hayk Mkrtchyan

I have 2 XML animations inside the animator folder. As they both are similar (scaling), I will send only one.

<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="3000"
android:interpolator="@android:interpolator/linear"
android:repeatCount="1"
android:repeatMode="reverse">

<propertyValuesHolder
    android:propertyName="scaleX"
    android:valueFrom="1"
    android:valueTo="2" />

<propertyValuesHolder
    android:propertyName="scaleY"
    android:valueFrom="1"
    android:valueTo="2" />

</objectAnimator>

So I load it in my fragment using AnimatorInflater.loadAnimator().

val animator = AnimatorInflater.loadAnimator(
        requireActivity(), R.animator.my_anim_file
    ).also { it.setTarget(binding.imageView) }

So when I launch my app on Android 5 or 5.1 it crashes with the following error message:

java.lang.RuntimeException: Unknown animator name: propertyValuesHolder

When I create ObjectAnimator programmatically, I don’t get an error. But what if I want to use the XML version? Why I’m getting this exception? Thank you.



Solution

This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?