{"record":{"id":"de1cebcddabcd2c4","repo":"bumptech/glide","slug":"unrecognized-uri-format-source","errorCode":null,"errorMessage":"Unrecognized Uri format: {source}","messagePattern":"Unrecognized Uri format: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"library/src/main/java/com/bumptech/glide/load/resource/drawable/ResourceDrawableDecoder.java","lineNumber":121,"sourceCode":"      // The parent APK holds the correct context if the resource is located in a split\n      if (packageName.contains(context.getPackageName())) {\n        return context;\n      }\n\n      throw new IllegalArgumentException(\n          \"Failed to obtain context or unrecognized Uri format for: \" + source, e);\n    }\n  }\n\n  @DrawableRes\n  private int findResourceIdFromUri(Context context, Uri source) {\n    List<String> segments = source.getPathSegments();\n    if (segments.size() == NAME_URI_PATH_SEGMENTS) {\n      return findResourceIdFromTypeAndNameResourceUri(context, source);\n    } else if (segments.size() == ID_PATH_SEGMENTS) {\n      return findResourceIdFromResourceIdUri(source);\n    } else {\n      throw new IllegalArgumentException(\"Unrecognized Uri format: \" + source);\n    }\n  }\n\n  // android.resource://com.android.camera2/mipmap/logo_camera_color\n  @DrawableRes\n  private int findResourceIdFromTypeAndNameResourceUri(Context context, Uri source) {\n    List<String> segments = source.getPathSegments();\n    String packageName = source.getAuthority();\n    String typeName = segments.get(TYPE_PATH_SEGMENT_INDEX);\n    String resourceName = segments.get(NAME_PATH_SEGMENT_INDEX);\n    int result = context.getResources().getIdentifier(resourceName, typeName, packageName);\n    if (result == MISSING_RESOURCE_ID) {\n      result = Resources.getSystem().getIdentifier(resourceName, typeName, ANDROID_PACKAGE_NAME);\n    }\n    if (result == MISSING_RESOURCE_ID) {\n      throw new IllegalArgumentException(\"Failed to find resource id for: \" + source);\n    }\n    return result;","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/bumptech/glide/blob/eb14a895d8f866e6a08c3e19d50ea3bd2c12c20a/library/src/main/java/com/bumptech/glide/load/resource/drawable/ResourceDrawableDecoder.java#L103-L139","documentation":"IllegalArgumentException thrown by ResourceDrawableDecoder.findResourceIdFromUri() when the number of path segments is neither 2 (type/name form) nor 1 (resource-id form). Glide only supports two android.resource:// URI shapes; anything else is rejected.","triggerScenarios":"Passing an android.resource:// URI with 0 or 3+ path segments, e.g. android.resource://com.example/ (zero segments) or android.resource://com.example/a/b/c.","commonSituations":"Manually constructing resource Uris and adding extra path components. Uri.parse on a string with trailing slashes creating empty segments. Confusing resource Uris with content: Uris.","solutions":["Use one of the two supported forms: android.resource://<package>/<type>/<name> or android.resource://<package>/<resId>.","Prefer Glide.with(ctx).load(resId) for your own resources.","Inspect source.getPathSegments().size() before handing the Uri to Glide."],"exampleFix":"// before\nUri uri = Uri.parse(\"android.resource://com.example/\"); // 0 segments\n// after\nUri uri = Uri.parse(\"android.resource://com.example/drawable/icon\");","handlingStrategy":"validation","validationCode":"// Validate path-segment count before loading.\nList<String> segs = uri.getPathSegments();\nboolean ok = \"android.resource\".equals(uri.getScheme())\n    && !TextUtils.isEmpty(uri.getAuthority())\n    && (segs.size() == 2 || segs.size() == 1);\nif (!ok) { /* rebuild or fall back */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Stick to the two supported android.resource URI forms.","Prefer .load(resId) for your own resources.","Validate segment count before loading."],"tags":["uri","drawable","resource","validation","android"],"backgroundTag":null,"analyzedSha":"eb14a895d8f866e6a08c3e19d50ea3bd2c12c20a","analyzedAt":"2026-08-14T01:43:54.821Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}