Search code examples
androidcompiler-errorsanimator

error: cannot find symbol class ofArgb


I'm trying to animate colors and I'm getting a strange error in Android Studio. My code:

import android.animation.ValueAnimator;

... later ...

ValueAnimator valueAnimator = new ValueAnimator.ofArgb(Color.YELLOW, Color.TRANSPARENT);

The following compilation error is thrown:

error: cannot find symbol class ofArgb

This seems to happen for other methods of ValueAnimator, like ofInt. It doesn't seem to happen for other Animators like ObjectAnimator.ofArgb which gives me a warning that it is SDK 21 and up.


Solution

  • new slipped in when it shouldn't have. Correct code:

    ValueAnimator valueAnimator = ValueAnimator.ofArgb(Color.YELLOW, Color.TRANSPARENT);
    

    Which correctly informs me that API 21 is required.

    Thanks Mike M.