{"record":{"id":"da3be81e7a1495f1","repo":"material-components/material-components-android","slug":"motion-path-theme-attribute-must-either-be-an-enum","errorCode":null,"errorMessage":"Motion path theme attribute must either be an enum value or path data string","messagePattern":"Motion path theme attribute must either be an enum value or path data string","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"lib/java/com/google/android/material/transition/TransitionUtils.java","lineNumber":114,"sourceCode":"  @Nullable\n  static PathMotion resolveThemePath(Context context, @AttrRes int attrResId) {\n    TypedValue pathValue = new TypedValue();\n    if (context.getTheme().resolveAttribute(attrResId, pathValue, true)) {\n      if (pathValue.type == TypedValue.TYPE_INT_DEC) {\n        int pathInt = pathValue.data;\n        if (pathInt == PATH_TYPE_LINEAR) {\n          // Default Transition PathMotion is linear; no need to override with different PathMotion.\n          return null;\n        } else if (pathInt == PATH_TYPE_ARC) {\n          return new MaterialArcMotion();\n        } else {\n          throw new IllegalArgumentException(\"Invalid motion path type: \" + pathInt);\n        }\n      } else if (pathValue.type == TypedValue.TYPE_STRING) {\n        String pathString = String.valueOf(pathValue.string);\n        return new PatternPathMotion(PathParser.createPathFromPathData(pathString));\n      } else {\n        throw new IllegalArgumentException(\n            \"Motion path theme attribute must either be an enum value or path data string\");\n      }\n    }\n    return null;\n  }\n\n  static ShapeAppearanceModel convertToRelativeCornerSizes(\n      ShapeAppearanceModel shapeAppearanceModel, final RectF bounds) {\n    return shapeAppearanceModel.withTransformedCornerSizes(\n        cornerSize -> RelativeCornerSize.createFromCornerSize(bounds, cornerSize));\n  }\n\n  // TODO: rethink how to interpolate more than just corner size\n  static ShapeAppearanceModel transformCornerSizes(\n      ShapeAppearanceModel shapeAppearanceModel1,\n      ShapeAppearanceModel shapeAppearanceModel2,\n      RectF shapeAppearanceModel1Bounds,\n      CornerSizeBinaryOperator op) {","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/material-components/material-components-android/blob/ac7e18efeefb331850c561faf9ab8bf81d27ba68/lib/java/com/google/android/material/transition/TransitionUtils.java#L96-L132","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"<!-- before -->\n<item name=\"motionPath\">@dimen/path_offset</item> <!-- wrong type -->\n\n<!-- after -->\n<item name=\"motionPath\">M0,0 L1,1</item> <!-- path data string -->","handlingStrategy":"validation","validationCode":"static boolean isAcceptableMotionPathType(TypedValue v) {\n  return v.type == TypedValue.TYPE_INT_DEC || v.type == TypedValue.TYPE_STRING;\n}\n// use in build-time/theme lint checks against every <item name=\"motionPath\"> entry","typeGuard":null,"tryCatchPattern":"try { pathMotion = resolveThemePath(ctx, attrId); } catch (IllegalArgumentException e) { pathMotion = null; /* default linear */ }","preventionTips":["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."],"tags":["android","material-components","theme","motion-path","resource-type","transition"],"backgroundTag":null,"analyzedSha":"ac7e18efeefb331850c561faf9ab8bf81d27ba68","analyzedAt":"2026-08-14T15:35:35.735Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}