airbnb/lottie-android · error · IllegalArgumentException

Unknown value for token of type {}

Error message

Unknown value for token of type {}

What it means

This method in JsonUtils reads a scalar float value from the JSON stream, handling NUMBER and BEGIN_ARRAY (single-element array) tokens. Any other token type — string, boolean, null, or object — triggers IllegalArgumentException. It is used during Lottie JSON parsing for properties expected to be numeric scalars.

Source

Thrown at lottie/src/main/java/com/airbnb/lottie/parser/JsonUtils.java:118

    reader.endObject();
    return new PointF(x * scale, y * scale);
  }

  static float valueFromObject(JsonReader reader) throws IOException {
    JsonReader.Token token = reader.peek();
    switch (token) {
      case NUMBER:
        return (float) reader.nextDouble();
      case BEGIN_ARRAY:
        reader.beginArray();
        float val = (float) reader.nextDouble();
        while (reader.hasNext()) {
          reader.skipValue();
        }
        reader.endArray();
        return val;
      default:
        throw new IllegalArgumentException("Unknown value for token of type " + token);
    }
  }
}

View on GitHub (pinned to 05ea92e903)

Solutions

  1. Validate the Lottie JSON with the LottieFiles validator and a standard JSON parser.
  2. Locate the offending property using the exception's file/line context, then correct the value to a valid number.
  3. Re-export or re-download the animation file.
Defensive patterns

Strategy: validation

Try / catch

LottieTask<LottieComposition> task = LottieCompositionFactory.fromAsset(context, name);
task.addListener(result -> { /* success */ })
     .addFailureListener(e -> { /* malformed JSON */ });

Prevention

When it happens

Trigger: A numeric property in the Lottie JSON (opacity, rotation, scale factor, etc.) contains a non-numeric JSON value such as a string, boolean, or null instead of a number or number array.

Common situations: Malformed Lottie animation where a numeric field was replaced with text or null; animation exported by a tool that uses a non-standard representation for scalar properties; truncated download producing a structural token shift.

Related errors


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