airbnb/lottie-android · error · UnsupportedOperationException
LottieAnimator does not support setDuration.
Error message
LottieAnimator does not support setDuration.
What it means
BaseLottieAnimator overrides ValueAnimator.setDuration(long) to unconditionally throw UnsupportedOperationException. Lottie animation duration is determined entirely by the composition's frame range (endFrame - startFrame) divided by the frame rate — it cannot be set externally. The override ensures callers cannot accidentally override the composition-derived duration.
Source
Thrown at lottie/src/main/java/com/airbnb/lottie/utils/BaseLottieAnimator.java:26
import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;
public abstract class BaseLottieAnimator extends ValueAnimator {
private final Set<ValueAnimator.AnimatorUpdateListener> updateListeners = new CopyOnWriteArraySet<>();
private final Set<AnimatorListener> listeners = new CopyOnWriteArraySet<>();
private final Set<Animator.AnimatorPauseListener> pauseListeners = new CopyOnWriteArraySet<>();
@Override public long getStartDelay() {
throw new UnsupportedOperationException("LottieAnimator does not support getStartDelay.");
}
@Override public void setStartDelay(long startDelay) {
throw new UnsupportedOperationException("LottieAnimator does not support setStartDelay.");
}
@Override public ValueAnimator setDuration(long duration) {
throw new UnsupportedOperationException("LottieAnimator does not support setDuration.");
}
@Override public void setInterpolator(TimeInterpolator value) {
throw new UnsupportedOperationException("LottieAnimator does not support setInterpolator.");
}
public void addUpdateListener(ValueAnimator.AnimatorUpdateListener listener) {
updateListeners.add(listener);
}
public void removeUpdateListener(ValueAnimator.AnimatorUpdateListener listener) {
updateListeners.remove(listener);
}
public void removeAllUpdateListeners() {
updateListeners.clear();
}
View on GitHub (pinned to 05ea92e903)
Solutions
- To control the effective playback range, use LottieAnimationView.setMinProgress()/setMaxProgress() or LottieValueAnimator.setMinFrame()/setMaxFrame() to limit which frames are played
- To change playback speed, use LottieAnimationView.setSpeed() or animator.setSpeed() — this effectively changes duration without setting it directly
- Remove any setDuration() calls on LottieAnimator instances from your code
Example fix
// before: animator.setDuration(2000); // after: // control effective duration via speed or frame range // // duration = frameRange / frameRate, so: // // to make it ~2s, adjust speed accordingly // float currentDuration = (maxFrame - minFrame) / frameRate * 1000f; // float speed = currentDuration / 2000f; // lottieAnimationView.setSpeed(speed); // lottieAnimationView.playAnimation();
Defensive patterns
Strategy: type-guard
Type guard
// Guard against calling setDuration on LottieAnimator
boolean isLottieAnimator(ValueAnimator animator) {
return animator instanceof com.airbnb.lottie.utils.BaseLottieAnimator;
}
// Safe access:
void safeSetDuration(ValueAnimator animator, long duration) {
if (animator instanceof com.airbnb.lottie.utils.BaseLottieAnimator) {
throw new IllegalArgumentException("Use setSpeed or setMinAndMaxFrame for LottieAnimator");
}
animator.setDuration(duration);
} Prevention
- Never call setDuration() on a LottieValueAnimator
- Control effective duration via setSpeed() or setMinAndMaxFrame()
- Type-check for BaseLottieAnimator in generic animation configuration code
When it happens
Trigger: Calling setDuration(ms) on a LottieValueAnimator, or on LottieAnimationView if it delegates to its internal animator. Also triggered by Android framework code or libraries that set duration generically on all ValueAnimators. The throw is at BaseLottieAnimator.java:26.
Common situations: A developer expects to control playback duration like a standard ValueAnimator. Code migrated from ObjectAnimator usage. Animation libraries that set duration on all animators. Using builder patterns or DSLs that chain .setDuration(). IDE auto-complete suggesting setDuration().
Related errors
- LottieAnimator does not support getStartDelay.
- LottieAnimator does not support setStartDelay.
- LottieAnimator does not support setInterpolator.
- You must provide a static value in the constructor , call se
- You must provide a static value in the constructor , call se
AI-assisted analysis of airbnb/lottie-android@05ea92e903 (2026-08-14).
Data as JSON: /api/errors/1c2570611d79e9f6.
Report an issue: GitHub.