koral--/android-gif-drawable · error · IllegalArgumentException
Only Config.ARGB_8888 is supported. Current bitmap config
Error message
Only Config.ARGB_8888 is supported. Current bitmap config: <config>
What it means
Native GIF rendering only supports ARGB_8888 pixel buffers; checkBuffer rejects any other Bitmap.Config (RGB_565, HARDWARE, etc.) with IllegalArgumentException, including the offending config in the message.
Solutions
- Create the buffer explicitly with Bitmap.Config.ARGB_8888
- If you have a non-8888 bitmap, copy it: bmp.copy(Bitmap.Config.ARGB_8888, false)
- Catch IllegalArgumentException, reallocate as ARGB_8888 and retry
Example fix
// before Bitmap buffer = Bitmap.createBitmap(w, h, Bitmap.Config.RGB_565); decoder.seekToTime(0, buffer); // after Bitmap buffer = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); decoder.seekToTime(0, buffer);
Defensive patterns
Strategy: validation
Validate before calling
if (buffer.getConfig() != Bitmap.Config.ARGB_8888) { buffer = buffer.copy(Bitmap.Config.ARGB_8888, false); } Type guard
Bitmap ensureArgb8888(Bitmap b) { return (b != null && b.getConfig() == Bitmap.Config.ARGB_8888) ? b : b.copy(Bitmap.Config.ARGB_8888, false); } Try / catch
try { decoder.seekToFrame(i, buffer); } catch (IllegalArgumentException e) { buffer = Bitmap.createBitmap(decoder.getWidth(), decoder.getHeight(), Bitmap.Config.ARGB_8888); decoder.seekToFrame(i, buffer); } Prevention
- Create seek buffers explicitly with Bitmap.Config.ARGB_8888
- Avoid passing HARDWARE-config bitmaps (common from Glide/UI APIs) into the decoder
- Check getConfig() when accepting bitmaps from external sources
When it happens
Trigger: Calling seekToTime/seekToFrame on GifDecoder with a bitmap created as RGB_565, or obtained from APIs returning HARDWARE config bitmaps (e.g. Glide-coalesced bitmaps on API 26+).
Common situations: Optimizing memory by choosing RGB_565; passing a bitmap received from an image-loading library that uses hardware bitmaps; copying a bitmap without forcing the config.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Sample size out of range <1, 65535>
- Bitmap is recycled
- Bitmap ia too small, size must be greater than or equal to…
- Position is not positive
- Frame index is not positive
AI-assisted analysis of koral--/android-gif-drawable@26ff795f78 (2026-09-10).
Data as JSON: /api/errors/2079841b7ea1507c.
Report an issue: GitHub.
Appendix: source
Thrown at android-gif-drawable/src/main/java/pl/droidsonroids/gif/GifDecoder.java:168
return mGifInfoHandle.getNumberOfFrames() > 1 && getDuration() > 0;
}
/**
* See {@link GifDrawable#recycle()}
*/
public void recycle() {
mGifInfoHandle.recycle();
}
private void checkBuffer(final Bitmap buffer) {
if (buffer.isRecycled()) {
throw new IllegalArgumentException("Bitmap is recycled");
}
if (buffer.getWidth() < mGifInfoHandle.getWidth() || buffer.getHeight() < mGifInfoHandle.getHeight()) {
throw new IllegalArgumentException("Bitmap ia too small, size must be greater than or equal to GIF size");
}
if (buffer.getConfig() != Bitmap.Config.ARGB_8888) {
throw new IllegalArgumentException("Only Config.ARGB_8888 is supported. Current bitmap config: " + buffer.getConfig());
}
}
}
View on GitHub (pinned to 26ff795f78)