{"record":{"id":"2079841b7ea1507c","repo":"koral--/android-gif-drawable","slug":"only-config-argb-8888-is-supported-current-bitmap","errorCode":null,"errorMessage":"Only Config.ARGB_8888 is supported. Current bitmap config: <config>","messagePattern":"Only Config\\.ARGB_8888 is supported\\. Current bitmap config: <config>","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"android-gif-drawable/src/main/java/pl/droidsonroids/gif/GifDecoder.java","lineNumber":168,"sourceCode":"\t\treturn mGifInfoHandle.getNumberOfFrames() > 1 && getDuration() > 0;\n\t}\n\n\t/**\n\t * See {@link GifDrawable#recycle()}\n\t */\n\tpublic void recycle() {\n\t\tmGifInfoHandle.recycle();\n\t}\n\n\tprivate void checkBuffer(final Bitmap buffer) {\n\t\tif (buffer.isRecycled()) {\n\t\t\tthrow new IllegalArgumentException(\"Bitmap is recycled\");\n\t\t}\n\t\tif (buffer.getWidth() < mGifInfoHandle.getWidth() || buffer.getHeight() < mGifInfoHandle.getHeight()) {\n\t\t\tthrow new IllegalArgumentException(\"Bitmap ia too small, size must be greater than or equal to GIF size\");\n\t\t}\n\t\tif (buffer.getConfig() != Bitmap.Config.ARGB_8888) {\n\t\t\tthrow new IllegalArgumentException(\"Only Config.ARGB_8888 is supported. Current bitmap config: \" + buffer.getConfig());\n\t\t}\n\t}\n}\n","sourceCodeStart":150,"sourceCodeEnd":172,"githubUrl":"https://github.com/koral--/android-gif-drawable/blob/26ff795f78b7fe8bbaf375a947b2bda95fc58e3d/android-gif-drawable/src/main/java/pl/droidsonroids/gif/GifDecoder.java#L150-L172","documentation":"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.","triggerScenarios":"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+).","commonSituations":"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.","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"],"exampleFix":"// before\nBitmap buffer = Bitmap.createBitmap(w, h, Bitmap.Config.RGB_565);\ndecoder.seekToTime(0, buffer);\n// after\nBitmap buffer = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);\ndecoder.seekToTime(0, buffer);","handlingStrategy":"validation","validationCode":"if (buffer.getConfig() != Bitmap.Config.ARGB_8888) { buffer = buffer.copy(Bitmap.Config.ARGB_8888, false); }","typeGuard":"Bitmap ensureArgb8888(Bitmap b) { return (b != null && b.getConfig() == Bitmap.Config.ARGB_8888) ? b : b.copy(Bitmap.Config.ARGB_8888, false); }","tryCatchPattern":"try { decoder.seekToFrame(i, buffer); } catch (IllegalArgumentException e) { buffer = Bitmap.createBitmap(decoder.getWidth(), decoder.getHeight(), Bitmap.Config.ARGB_8888); decoder.seekToFrame(i, buffer); }","preventionTips":["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"],"tags":["android","gif","bitmap-config"],"backgroundTag":"invalid-argument-value","analyzedSha":"26ff795f78b7fe8bbaf375a947b2bda95fc58e3d","analyzedAt":"2026-09-10T14:37:11.595Z","contentChangedAt":"2026-09-10T14:37:11.595Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}