material-components/material-components-android · error · IllegalArgumentException
Invalid motion path type: > pathInt <
Error message
Invalid motion path type: > pathInt <
What it means
TransitionUtils.resolveThemePath reads the theme attribute referenced by a Material transition's motionPath attr. When the resolved TypedValue is an integer (TYPE_INT_DEC) it must be one of the declared enum values: 0 = linear (no PathMotion override) or 1 = arc (MaterialArcMotion). Any other integer — 2, -1, or a plain int that is not part of the enum — throws IllegalArgumentException('Invalid motion path type: ' + pathInt). This guards the enum contract declared in the attr's format.
Source
Thrown at lib/java/com/google/android/material/transition/platform/TransitionUtils.java:113
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
- Set the theme attribute to a valid enum: <item name="motionPath">@enum/linear or the integer 0, or arc/1, or a path-data string like "M0,0 L100,0".
- Search the whole theme chain (base theme, overlays, themes.xml values-night etc.) for the motionPath item and remove stale literals: grep for the attr name across res/values*.
- If you need a custom curve, pass a path string (TYPE_STRING) instead of an out-of-range int.
- If inherited from a library theme, override the attribute locally with a valid value in your app theme.
Example fix
<!-- before --> <item name="motionPath">2</item> <!-- after --> <item name="motionPath">@enum/linear</item> <!-- or a custom curve --> <item name="motionPath">M0,0 L100,100</item>
Defensive patterns
Strategy: validation
Validate before calling
// Verify the theme-supplied value before applying a transition that resolves it.
TypedValue v = new TypedValue();
if (context.getTheme().resolveAttribute(R.attr.motionPath, v, true)) {
boolean ok = v.type == TypedValue.TYPE_STRING
|| (v.type == TypedValue.TYPE_INT_DEC && (v.data == 0 || v.data == 1));
if (!ok) throw new IllegalStateException("Fix motionPath in theme to 0, 1, or path data");
} Try / catch
try {
transition.setPathMotion(TransitionUtils.resolveThemePath(context, attr)); // example
} catch (IllegalArgumentException e) {
if (e.getMessage() != null && e.getMessage().startsWith("Invalid motion path type")) {
Log.w(TAG, "motionPath enum out of range; defaulting to linear", e);
transition.setPathMotion(null); // null PathMotion = linear default
} else {
throw e;
}
} Prevention
- Declare the motionPath attr as format="enum|string" so invalid values fail at build time.
- Use enum names (@enum/linear, @enum/arc) rather than raw ints in themes.
- Audit merged resources (Material Theme Overlay, values-night) after library upgrades for stale literals.
When it happens
Trigger: A theme (often a base theme or overlay) sets the transition's motionPath attribute to a raw integer other than 0/1, e.g. <item name="motionPath">2</item>; a build tool or lint override substitutes the enum with a wrong constant; the attr was redeclared in the app with a different enum set and a stale value leaks in.
Common situations: Hand-editing generated theme XML and replacing @enum values with plain ints; themes inherited from a design system where motionPath was redefined; upgrading Material versions where the attr moved and an old literal value (e.g., a leftover 2 from a removed 'through' mode) survives.
Related errors
- Invalid motion path type: > pathInt <
- Motion path theme attribute must either be an enum value or
- Motion path theme attribute must either be an enum value or
- %1$s requires a value for the %2$s attribute to be set in yo
- Invalid axis: > axis <
AI-assisted analysis of material-components/material-components-android@ac7e18efee (2026-08-14).
Data as JSON: /api/errors/7200c3d5bd9a5947.
Report an issue: GitHub.