bumptech/glide · error · IllegalArgumentException

Unable to convert {drawable} to a Bitmap

Error message

Unable to convert {drawable} to a Bitmap

What it means

Thrown by DrawableTransformation when DrawableToBitmapConverter.convert() returns null and the transformation is marked required (isRequired=true). The converter returns null for drawables that have no intrinsic size and cannot be rendered to a bitmap; when required, Glide refuses to silently skip the transformation.

Source

Thrown at library/src/main/java/com/bumptech/glide/load/resource/bitmap/DrawableTransformation.java:55

    this.isRequired = isRequired;
  }

  @SuppressWarnings("unchecked")
  public Transformation<BitmapDrawable> asBitmapDrawable() {
    return (Transformation<BitmapDrawable>) (Transformation<?>) this;
  }

  @NonNull
  @Override
  public Resource<Drawable> transform(
      @NonNull Context context, @NonNull Resource<Drawable> resource, int outWidth, int outHeight) {
    BitmapPool bitmapPool = Glide.get(context).getBitmapPool();
    Drawable drawable = resource.get();
    Resource<Bitmap> bitmapResourceToTransform =
        DrawableToBitmapConverter.convert(bitmapPool, drawable, outWidth, outHeight);
    if (bitmapResourceToTransform == null) {
      if (isRequired) {
        throw new IllegalArgumentException("Unable to convert " + drawable + " to a Bitmap");
      } else {
        return resource;
      }
    }
    Resource<Bitmap> transformedBitmapResource =
        wrapped.transform(context, bitmapResourceToTransform, outWidth, outHeight);

    if (transformedBitmapResource.equals(bitmapResourceToTransform)) {
      transformedBitmapResource.recycle();
      return resource;
    } else {
      return newDrawableResource(context, transformedBitmapResource);
    }
  }

  // It's clearer to cast the result in a separate line from obtaining it.
  @SuppressWarnings({"unchecked", "PMD.UnnecessaryLocalBeforeReturn"})
  private Resource<Drawable> newDrawableResource(Context context, Resource<Bitmap> transformed) {

View on GitHub (pinned to eb14a895d8)

Solutions

  1. Supply concrete dimensions via .override(width, height) so the converter has a target size.
  2. Construct DrawableTransformation with isRequired=false if skipping the transformation is acceptable.
  3. Load the resource as Drawable (.asDrawable()) instead of forcing .asBitmap() when the source is shape-based.
  4. Replace the drawable source with one that has intrinsic dimensions, or wrap it in a sized container.

Example fix

// before
Glide.with(ctx).load(colorDrawableUri).asBitmap().transform(new CenterCrop()).into(img);
// after
Glide.with(ctx).load(colorDrawableUri).asBitmap()
  .override(img.getWidth(), img.getHeight())
  .transform(new CenterCrop()).into(img);
Defensive patterns

Strategy: validation

Validate before calling

// Provide explicit dimensions so DrawableToBitmapConverter has a target size.
int w = target.getWidth() > 0 ? target.getWidth() : 1080;
int h = target.getHeight() > 0 ? target.getHeight() : 1920;
Glide.with(ctx).asBitmap()
  .override(w, h)
  .load(drawableSource)
  .transform(new CenterCrop())
  .into(target);

Prevention

When it happens

Trigger: Applying a BitmapTransformation-based wrapper to a Drawable (e.g. asBitmap() or transform() with a Drawable source) where the drawable has intrinsic width/height of -1 (e.g. some ColorDrawable or shape-less drawables) and no concrete size is supplied.

Common situations: Calling .asBitmap().transform(new CenterCrop()) on a VectorDrawable or AdaptiveIconDrawable with -1 intrinsic dimensions. Loading a ColorDrawable through a bitmap pipeline without providing override dimensions.

Related errors


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