material-components/material-components-android · error · IllegalArgumentException

Invalid motion path type: > pathInt <

Error message

Invalid motion path type: > pathInt <

What it means

TransitionUtils.resolveThemePath (TransitionUtils.java:108) reads a motion-path theme attribute (e.g. motionPath) for container transforms. When the attribute resolves to an integer enum it must be PATH_TYPE_LINEAR (0) or PATH_TYPE_ARC (1); any other int throws IllegalArgumentException with the offending value. The int is meant to come from an <enum> declared in attrs, so an out-of-range value means malformed theme XML or an int injected programmatically via a theme overlay.

Source

Thrown at lib/java/com/google/android/material/transition/TransitionUtils.java:108

        return true;
      }
    }
    return false;
  }

  @Nullable
  static PathMotion resolveThemePath(Context context, @AttrRes int attrResId) {
    TypedValue pathValue = new TypedValue();
    if (context.getTheme().resolveAttribute(attrResId, pathValue, true)) {
      if (pathValue.type == TypedValue.TYPE_INT_DEC) {
        int pathInt = pathValue.data;
        if (pathInt == PATH_TYPE_LINEAR) {
          // Default Transition PathMotion is linear; no need to override with different PathMotion.
          return null;
        } else if (pathInt == PATH_TYPE_ARC) {
          return new MaterialArcMotion();
        } else {
          throw new IllegalArgumentException("Invalid motion path type: " + pathInt);
        }
      } else if (pathValue.type == TypedValue.TYPE_STRING) {
        String pathString = String.valueOf(pathValue.string);
        return new PatternPathMotion(PathParser.createPathFromPathData(pathString));
      } else {
        throw new IllegalArgumentException(
            "Motion path theme attribute must either be an enum value or path data string");
      }
    }
    return null;
  }

  static ShapeAppearanceModel convertToRelativeCornerSizes(
      ShapeAppearanceModel shapeAppearanceModel, final RectF bounds) {
    return shapeAppearanceModel.withTransformedCornerSizes(
        cornerSize -> RelativeCornerSize.createFromCornerSize(bounds, cornerSize));
  }

View on GitHub (pinned to ac7e18efee)

Solutions

  1. In the theme, use only the declared enum values for the motion path attribute (linear or arc).
  2. If a path shape is needed, supply path-data string syntax instead of an int (e.g. a path string like "M0,0 L100,100"), which takes the TYPE_STRING branch.
  3. Sync material library versions across modules so enum constants match at runtime.

Example fix

<!-- before -->
<style name="AppTheme" parent="...">
  <item name="motionPath">2</item> <!-- invalid enum int -->
</style>

<!-- after -->
<style name="AppTheme" parent="...">
  <item name="motionPath">arc</item> <!-- or omit for default linear -->
</style>
Defensive patterns

Strategy: validation

Validate before calling

// theme values can't be intercepted in Java; validate the XML at build time instead
// e.g. a unit test parsing styles for the motionPath item:
// assert value is one of {linear enum(0), arc enum(1)} or a path-data string
static boolean isValidMotionPathValue(TypedValue v) {
  if (v.type == TypedValue.TYPE_INT_DEC) return v.data == 0 || v.data == 1;
  return v.type == TypedValue.TYPE_STRING;
}

Try / catch

try { resolveThemePath(context, attr); } catch (IllegalArgumentException e) { /* fall back to default linear path */ return null; } // appropriate since linear is a safe default

Prevention

When it happens

Trigger: A theme/overlay defining the motion-path attr with an int other than 0 or 1 (e.g. android:value="2" or an out-of-sync enum constant); reusing a stale R.attr value after library update changed the enum space; programmatic themes (MaterialThemeDrawable/theme overlay XML) with a hand-written integer.

Common situations: Hand-editing enum values in a theme; library version mismatch where an app module compiled against different constants than the resolved material library; copy-pasting a motionPath attr config from an incompatible fork.

Related errors


AI-assisted analysis of material-components/material-components-android@ac7e18efee (2026-08-14). Data as JSON: /api/errors/4cd4233e81b7f856. Report an issue: GitHub.