material-components/material-components-android · error · IllegalArgumentException
Motion path theme attribute must either be an enum value or
Error message
Motion path theme attribute must either be an enum value or path data string
What it means
In TransitionUtils.resolveThemePath (TransitionUtils.java:114), when the resolved motion-path theme attribute's TypedValue type is neither TYPE_INT_DEC (enum) nor TYPE_STRING (path data) — for example a color, float, dimension, or boolean — the method throws IllegalArgumentException. The attribute has a strictly two-shaped contract: an enum int or a path-data string; any other resource type is a theme authoring error.
Source
Thrown at lib/java/com/google/android/material/transition/TransitionUtils.java:114
@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));
}
// TODO: rethink how to interpolate more than just corner size
static ShapeAppearanceModel transformCornerSizes(
ShapeAppearanceModel shapeAppearanceModel1,
ShapeAppearanceModel shapeAppearanceModel2,
RectF shapeAppearanceModel1Bounds,
CornerSizeBinaryOperator op) {View on GitHub (pinned to ac7e18efee)
Solutions
- Supply either an enum value or a path-data string for the motion-path attr — nothing else.
- Check the attr declaration/format in values/attrs and remove any app-side redefinition that widens or changes the type.
- Lint theme overlays for the motionPath item type before release builds.
Example fix
<!-- before --> <item name="motionPath">@dimen/path_offset</item> <!-- wrong type --> <!-- after --> <item name="motionPath">M0,0 L1,1</item> <!-- path data string -->
Defensive patterns
Strategy: validation
Validate before calling
static boolean isAcceptableMotionPathType(TypedValue v) {
return v.type == TypedValue.TYPE_INT_DEC || v.type == TypedValue.TYPE_STRING;
}
// use in build-time/theme lint checks against every <item name="motionPath"> entry Try / catch
try { pathMotion = resolveThemePath(ctx, attrId); } catch (IllegalArgumentException e) { pathMotion = null; /* default linear */ } Prevention
- Never point the motion-path attr at dimensions, colors, booleans or floats.
- Remove app-side attr redefinitions that widen the library's format.
- Test the full theme (including overlays) on a device or in Robolectric before release.
When it happens
Trigger: Setting the motion-path theme attr to @dimen/slide_dist, a float, a boolean, or a color reference; using a format-mismatched resource (attr declared format="enum|string" but supplied a dimension); aapt resolving an <item> to an unexpected TypedValue type.
Common situations: Theme XML edited by hand with the wrong resource type; attr redefinition in the app colliding with the library attr and loosening its format; migrating theme values where a dimension accidentally replaces the path config.
Related errors
- Invalid motion path type: > pathInt <
- Invalid motion path type: > pathInt <
- 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/da3be81e7a1495f1.
Report an issue: GitHub.