{"record":{"id":"906eac3b7947957d","repo":"material-components/material-components-android","slug":"not-supported-with-unknown-package-id-packageid","errorCode":null,"errorMessage":"Not supported with unknown package id: {packageId}","messagePattern":"Not supported with unknown package id: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"lib/java/com/google/android/material/color/ColorResourcesTableCreator.java","lineNumber":99,"sourceCode":"              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=\"\n                + colorResource.name\n                + \", typeId=\"\n                + Integer.toHexString(colorResource.typeId & 0xFF));\n      }\n      PackageInfo packageInfo;\n      if (colorResource.packageId == ANDROID_PACKAGE_ID) {\n        packageInfo = ANDROID_PACKAGE_INFO;\n      } else if (colorResource.packageId == APPLICATION_PACKAGE_ID) {\n        packageInfo = applicationPackageInfo;\n      } else {\n        throw new IllegalArgumentException(\n            \"Not supported with unknown package id: \" + colorResource.packageId);\n      }\n      if (!colorResourceMap.containsKey(packageInfo)) {\n        colorResourceMap.put(packageInfo, new ArrayList<ColorResource>());\n      }\n      colorResourceMap.get(packageInfo).add(colorResource);\n    }\n    // Resource Type Ids are assigned by aapt arbitrarily, for each new type the next available\n    // number is assigned and used. The type id will be the same for resources that are the same\n    // type.\n    typeIdColor = colorResource.typeId;\n    if (typeIdColor == 0) {\n      throw new IllegalArgumentException(\"No color resources found for harmonization.\");\n    }\n    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();\n    new ResTable(colorResourceMap).writeTo(outputStream);\n    return outputStream.toByteArray();\n  }","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/material-components/material-components-android/blob/ac7e18efeefb331850c561faf9ab8bf81d27ba68/lib/java/com/google/android/material/color/ColorResourcesTableCreator.java#L81-L117","documentation":"Each color resource's package ID must be either 0x01 (the android framework package) or the application package ID (0x7f by default) for the generated resources table to be well-formed. Any other package id throws IllegalArgumentException, because the table writer has no package chunk to represent it.","triggerScenarios":"Passing a color resource ID belonging to a dynamic feature module, an AAR with a non-standard package id, or an R class from another app/context (e.g. resolving colors from a different application's Resources); runtimes that assign custom package ids to shared libraries.","commonSituations":"Multi-module apps mixing R constants from feature modules resolved through a different Context; device builds with non-standard resource package ids (some OEM/shared-library configurations); using resources obtained from another package's context in the harmonization map.","solutions":["Only pass application (R.color.*) or android (android.R.color.*) color ids in the mapping.","Ensure the Context passed to create() is the application context that owns the resources in the map.","Copy cross-package colors into your own res/colors before mapping them."],"exampleFix":"// before (otherAppResources resolves to a foreign package id)\nval overrides = mapOf(otherAppResources.getIdentifier(\"brand\" ,\"color\", \"com.other\") to newColor)\nColorResourcesTableCreator.create(context, overrides) // throws\n\n// after\ncolors.xml: <color name=\"brand\">#FF00FF</color>\nval overrides = mapOf(R.color.brand to newColor)","handlingStrategy":"validation","validationCode":"fun isSupportedPackageId(id: Int): Boolean {\n  val packageId = (id ushr 24) and 0xFF\n  return packageId == 0x01 || packageId == 0x7f\n}\n\nval safeMap = colorMapping.filterKeys { isSupportedPackageId(it) }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass only your app's R.color constants or android.R.color constants.","Use the application context when creating the resources table.","Copy foreign-package colors into your own res before overriding them."],"tags":["android","material-components","dynamic-color","resources","package-id"],"backgroundTag":null,"analyzedSha":"ac7e18efeefb331850c561faf9ab8bf81d27ba68","analyzedAt":"2026-08-14T15:35:35.735Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}