{"record":{"id":"1419d2420560f4ff","repo":"material-components/material-components-android","slug":"no-color-resources-provided-for-harmonization","errorCode":null,"errorMessage":"No color resources provided for harmonization.","messagePattern":"No color resources provided for harmonization\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"lib/java/com/google/android/material/color/ColorResourcesTableCreator.java","lineNumber":70,"sourceCode":"\n  private static final String RESOURCE_TYPE_NAME_COLOR = \"color\";\n\n  private static byte typeIdColor;\n\n  private static final PackageInfo ANDROID_PACKAGE_INFO =\n      new PackageInfo(ANDROID_PACKAGE_ID, \"android\");\n\n  private static final Comparator<ColorResource> COLOR_RESOURCE_COMPARATOR =\n      new Comparator<ColorResource>() {\n        @Override\n        public int compare(ColorResource res1, ColorResource res2) {\n          return res1.entryId - res2.entryId;\n        }\n      };\n\n  static byte[] create(Context context, Map<Integer, Integer> colorMapping) throws IOException {\n    if (colorMapping.entrySet().isEmpty()) {\n      throw new IllegalArgumentException(\"No color resources provided for harmonization.\");\n    }\n    PackageInfo applicationPackageInfo =\n        new PackageInfo(APPLICATION_PACKAGE_ID, context.getPackageName());\n\n    Map<PackageInfo, List<ColorResource>> colorResourceMap = new HashMap<>();\n    ColorResource colorResource = null;\n    for (Map.Entry<Integer, Integer> entry : colorMapping.entrySet()) {\n      colorResource =\n          new ColorResource(\n              entry.getKey(),\n              context.getResources().getResourceEntryName(entry.getKey()),\n              entry.getValue());\n      if (!context\n          .getResources()\n          .getResourceTypeName(entry.getKey())\n          .equals(RESOURCE_TYPE_NAME_COLOR)) {\n        throw new IllegalArgumentException(\n            \"Non color resource found: name=\"","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/material-components/material-components-android/blob/ac7e18efeefb331850c561faf9ab8bf81d27ba68/lib/java/com/google/android/material/color/ColorResourcesTableCreator.java#L52-L88","documentation":"ColorResourcesTableCreator.create(context, colorMapping) builds a runtime resources table (arsc blob) for color harmonization/override. An empty mapping means there is nothing to write, so the method fails fast with IllegalArgumentException rather than producing a broken table. Callers reach it via DynamicColors/DynamicColorsOptions with harmonized or color override maps.","triggerScenarios":"Calling ColorResourcesTableCreator.create(context, emptyMap()) directly; passing DynamicColorsOptions built with an empty colorOverride or colorOverrideMap; filtering a color map down to empty before applying dynamic colors.","commonSituations":"Feature-flagged theming where the override map is built from server config and comes back empty; generic 'apply overrides' helpers that forward whatever map they receive.","solutions":["Skip the harmonization/override call entirely when the map is empty: if (colorMapping.isEmpty()) return.","Ensure the code building the color override map always adds the intended color resources.","If using DynamicColors, only enable colorOverrideToResourceIds/DynamicColorsOptions when at least one override exists."],"exampleFix":"// before\nColorResourcesTableCreator.create(context, emptyMap()) // throws\n\n// after\nif (colorMapping.isNotEmpty()) {\n  ColorResourcesTableCreator.create(context, colorMapping)\n}","handlingStrategy":"validation","validationCode":"fun applyHarmonization(context: Context, colorMapping: Map<Int, Int>) {\n  if (colorMapping.isEmpty()) return // guard: nothing to harmonize\n  ColorResourcesTableCreator.create(context, colorMapping)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check map emptiness before any dynamic-color override call.","Log when theming config resolves to zero overrides; it usually indicates a config bug.","Build override maps from typed resource constants, not free-form config."],"tags":["android","material-components","dynamic-color","resources","validation"],"backgroundTag":null,"analyzedSha":"ac7e18efeefb331850c561faf9ab8bf81d27ba68","analyzedAt":"2026-08-14T15:35:35.735Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}