airbnb/lottie-android · error · IllegalStateException

Merge paths are not supported pre-KitKat.

Error message

Merge paths are not supported pre-KitKat.

What it means

Thrown by MergePathsContent's constructor when Build.VERSION.SDK_INT is below KITKAT (API 19). Merge paths rely on android.graphics.Path#op(Path, Op), which was added in KitKat, so the feature cannot be constructed on older devices.

Source

Thrown at lottie/src/main/java/com/airbnb/lottie/animation/content/MergePathsContent.java:25

import com.airbnb.lottie.model.content.MergePaths;

import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;

@TargetApi(Build.VERSION_CODES.KITKAT)
public class MergePathsContent implements PathContent, GreedyContent {
  private final Path firstPath = new Path();
  private final Path remainderPath = new Path();
  private final Path path = new Path();

  private final String name;
  private final List<PathContent> pathContents = new ArrayList<>();
  private final MergePaths mergePaths;

  public MergePathsContent(MergePaths mergePaths) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
      throw new IllegalStateException("Merge paths are not supported pre-KitKat.");
    }
    name = mergePaths.getName();
    this.mergePaths = mergePaths;
  }

  @Override public void absorbContent(ListIterator<Content> contents) {
    // Fast forward the iterator until after this content.
    //noinspection StatementWithEmptyBody
    while (contents.hasPrevious() && contents.previous() != this) {
    }
    while (contents.hasPrevious()) {
      Content content = contents.previous();
      if (content instanceof PathContent) {
        pathContents.add((PathContent) content);
        contents.remove();
      }
    }
  }

View on GitHub (pinned to 05ea92e903)

Solutions

  1. Raise minSdkVersion to 19+ if you can drop pre-KitKat support.
  2. Remove/replace merge-path layers in the After Effects source and re-export for pre-KitKat compatibility.
  3. Gate playback: skip or substitute the animation when Build.VERSION.SDK_INT < KITKAT.
  4. Use LottieCompositionFactory with a failure listener so older devices degrade gracefully.

Example fix

// before
lottieAnimationView.setAnimation(R.raw.merge_anim);

// after
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
  lottieAnimationView.setAnimation(R.raw.merge_anim);
} else {
  lottieAnimationView.setAnimation(R.raw.fallback_anim);
}
Defensive patterns

Strategy: validation

Validate before calling

boolean canPlayMergePaths = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
int res = canPlayMergePaths ? R.raw.merge_anim : R.raw.fallback_anim;
lottieAnimationView.setAnimation(res);

Type guard

boolean supportsMergePaths() {
  return Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
}

Prevention

When it happens

Trigger: Loading an animation that contains merge paths (compositing operations exported from After Effects) on a device running Android API < 19; minSdkVersion below 19 with such an animation.

Common situations: Shipping to legacy device ranges; an artist adding a merge-path layer to an animation that previously ran on old devices; lowering minSdkVersion without auditing assets.


AI-assisted analysis of airbnb/lottie-android@05ea92e903 (2026-08-14). Data as JSON: /api/errors/689ed54020bb45ce. Report an issue: GitHub.