bumptech/glide · error · IllegalArgumentException

Failed to find resource id for: {source}

Error message

Failed to find resource id for: {source}

What it means

IllegalArgumentException thrown by ResourceDrawableDecoder.findResourceIdFromTypeAndNameResourceUri() when neither the target package's Resources nor the system android package yield a resource id for the given type/name pair. The resource simply does not exist under that name.

Source

Thrown at library/src/main/java/com/bumptech/glide/load/resource/drawable/ResourceDrawableDecoder.java:137

      return findResourceIdFromResourceIdUri(source);
    } else {
      throw new IllegalArgumentException("Unrecognized Uri format: " + source);
    }
  }

  // android.resource://com.android.camera2/mipmap/logo_camera_color
  @DrawableRes
  private int findResourceIdFromTypeAndNameResourceUri(Context context, Uri source) {
    List<String> segments = source.getPathSegments();
    String packageName = source.getAuthority();
    String typeName = segments.get(TYPE_PATH_SEGMENT_INDEX);
    String resourceName = segments.get(NAME_PATH_SEGMENT_INDEX);
    int result = context.getResources().getIdentifier(resourceName, typeName, packageName);
    if (result == MISSING_RESOURCE_ID) {
      result = Resources.getSystem().getIdentifier(resourceName, typeName, ANDROID_PACKAGE_NAME);
    }
    if (result == MISSING_RESOURCE_ID) {
      throw new IllegalArgumentException("Failed to find resource id for: " + source);
    }
    return result;
  }

  // android.resource://com.android.camera2/123456
  @DrawableRes
  private int findResourceIdFromResourceIdUri(Uri source) {
    List<String> segments = source.getPathSegments();
    try {
      return Integer.parseInt(segments.get(RESOURCE_ID_SEGMENT_INDEX));
    } catch (NumberFormatException e) {
      throw new IllegalArgumentException("Unrecognized Uri format: " + source, e);
    }
  }
}

View on GitHub (pinned to eb14a895d8)

Solutions

  1. Verify the resource name and type exist via Resources.getIdentifier(...) == non-zero before loading.
  2. Prefer integer resIds over names when loading your own resources.
  3. Add an .error() fallback for missing resources.
  4. Double-check the type segment (drawable vs mipmap vs raw).

Example fix

// before
Uri uri = Uri.parse("android.resource://com.example/drawable/icon_old");
Glide.with(ctx).load(uri).into(img);
// after
Resources res = ctx.getResources();
int id = res.getIdentifier("icon_old", "drawable", "com.example");
if (id != 0) {
  Glide.with(ctx).load(id).into(img);
} else {
  img.setImageResource(R.drawable.placeholder);
}
Defensive patterns

Strategy: validation

Validate before calling

// Look up the resource id first; fall back if missing.
int id = ctx.getResources().getIdentifier(name, type, packageName);
if (id == 0) id = Resources.getSystem().getIdentifier(name, type, "android");
if (id == 0) { /* show placeholder */ } else { Glide.with(ctx).load(id).into(img); }

Prevention

When it happens

Trigger: Loading android.resource://<package>/<type>/<name> where <name> does not exist in <type> of <package>. Typo in resource name, wrong type, or renamed/removed resource.

Common situations: Hardcoding drawable names that get renamed during refactors. Loading resources from third-party packages whose names change between versions. Wrong type (e.g. mipmap vs drawable).

Related errors


AI-assisted analysis of bumptech/glide@eb14a895d8 (2026-08-14). Data as JSON: /api/errors/5f177d69b379dee9. Report an issue: GitHub.