didi/DoKit · error · IllegalArgumentException
Bitmap config must not be null.
Error message
Bitmap config must not be null.
What it means
Builder.defaultBitmapConfig(Bitmap.Config) sets the default decode config for the whole instance (e.g. RGB_565 to halve memory). Passing null is rejected with IllegalArgumentException('Bitmap config must not be null.') because BitmapFactory.decode* with a null inPreferredConfig behaves differently across API levels — Picasso requires an explicit choice. Per-request overrides via RequestCreator.config() carry the same rule.
Source
Thrown at Android/dokit/src/main/java/com/didichuxing/doraemonkit/picasso/DokitPicasso.java:713
private boolean indicatorsEnabled;
private boolean loggingEnabled;
/** Start building a new {@link DokitPicasso} instance. */
public Builder(Context context) {
if (context == null) {
throw new IllegalArgumentException("Context must not be null.");
}
this.context = context.getApplicationContext();
}
/**
* Specify the default {@link Bitmap.Config} used when decoding images. This can be overridden
* on a per-request basis using {@link RequestCreator#config(Bitmap.Config) config(..)}.
*/
public Builder defaultBitmapConfig(Bitmap.Config bitmapConfig) {
if (bitmapConfig == null) {
throw new IllegalArgumentException("Bitmap config must not be null.");
}
this.defaultBitmapConfig = bitmapConfig;
return this;
}
/** Specify the {@link Downloader} that will be used for downloading images. */
public Builder downloader(Downloader downloader) {
if (downloader == null) {
throw new IllegalArgumentException("Downloader must not be null.");
}
if (this.downloader != null) {
throw new IllegalStateException("Downloader already set.");
}
this.downloader = downloader;
return this;
}
/**View on GitHub (pinned to 626827cddb)
Solutions
- Default to Bitmap.Config.ARGB_8888 when your selection logic yields null
- Gate API-specific configs: use RGBA_F16/HARDWARE only on supported API levels
- Remember Picasso already defaults to ARGB_8888 internally — only call this method when you actually have a config to set
Example fix
// before
Bitmap.Config cfg = prefs.getBoolean("lowMem", false) ? Bitmap.Config.RGB_565 : null;
new DokitPicasso.Builder(context).defaultBitmapConfig(cfg).build();
// after
Bitmap.Config cfg = prefs.getBoolean("lowMem", false)
? Bitmap.Config.RGB_565 : Bitmap.Config.ARGB_8888;
new DokitPicasso.Builder(context).defaultBitmapConfig(cfg).build(); Defensive patterns
Strategy: validation
Validate before calling
Bitmap.Config config = lowMemory ? Bitmap.Config.RGB_565 : Bitmap.Config.ARGB_8888; DokitPicasso picasso = new DokitPicasso.Builder(context).defaultBitmapConfig(config).build();
Try / catch
try {
builder.defaultBitmapConfig(config);
} catch (IllegalArgumentException e) {
if ("Bitmap config must not be null.".equals(e.getMessage())) {
builder.defaultBitmapConfig(Bitmap.Config.ARGB_8888);
} else throw e;
} Prevention
- Always resolve to an explicit config — default to ARGB_8888 when in doubt
- Gate API-level-specific configs (HARDWARE, RGBA_F16) behind Build.VERSION checks
- If you have no strong opinion, omit the call entirely; Picasso's internal default is ARGB_8888
When it happens
Trigger: Builder.defaultBitmapConfig(null) from a variable that failed to initialize; reading the config from a preference/API-gated path where the value is null on old devices (some Bitmap.Config constants are API-level specific); calling .config(null) per request.
Common situations: Memory-tuning code that conditionally selects ARGB_8888/RGBA_F16 and has no fallback branch; HARDWARE config used below API 26.
Related errors
- Downloader must not be null.
- Transformation " + transformation.key() + " crashed with exc
- Transformation " + transformation.key() + " returned null af
- Transformation " + transformation.key() + " returned input B
- Transformation <transformation.key()> mutated input Bitmap b
AI-assisted analysis of didi/DoKit@626827cddb (2026-08-14).
Data as JSON: /api/errors/72163756623b5124.
Report an issue: GitHub.