didi/DoKit · error · IllegalArgumentException
Listener must not be null.
Error message
Listener must not be null.
What it means
DokitPicasso.Builder.listener() throws IllegalArgumentException when passed a null Listener. The listener receives callbacks for failed image loads, so it must be a real object. This is a fail-fast null guard.
Source
Thrown at Android/dokit/src/main/java/com/didichuxing/doraemonkit/picasso/DokitPicasso.java:762
return this;
}
/** Specify the memory cache used for the most recent images. */
public Builder memoryCache(Cache memoryCache) {
if (memoryCache == null) {
throw new IllegalArgumentException("Memory cache must not be null.");
}
if (this.cache != null) {
throw new IllegalStateException("Memory cache already set.");
}
this.cache = memoryCache;
return this;
}
/** Specify a listener for interesting events. */
public Builder listener(Listener listener) {
if (listener == null) {
throw new IllegalArgumentException("Listener must not be null.");
}
if (this.listener != null) {
throw new IllegalStateException("Listener already set.");
}
this.listener = listener;
return this;
}
/**
* Specify a transformer for all incoming requests.
* <p>
* <b>NOTE:</b> This is a beta feature. The API is subject to change in a backwards incompatible
* way at any time.
*/
public Builder requestTransformer(RequestTransformer transformer) {
if (transformer == null) {
throw new IllegalArgumentException("Transformer must not be null.");
}View on GitHub (pinned to 626827cddb)
Solutions
- Pass a non-null Listener implementation
- Guard the call: only invoke listener() when you have a real listener to install
- If no callbacks are needed, omit listener() entirely
Example fix
// before
Listener l = buildConfigDebug ? new DebugListener() : null;
builder.listener(l); // IllegalArgumentException in release
// after
if (buildConfigDebug) {
builder.listener(new DebugListener());
} Defensive patterns
Strategy: validation
Validate before calling
if (listener != null) { builder.listener(listener); } Prevention
- Guard optional components (debug listeners) with null checks before registering
- Build release-safe defaults instead of nullable listener references
When it happens
Trigger: Calling builder.listener(null), commonly from an optional debug listener that was left unset in release builds.
Common situations: Debug-only listener wrapped in an if (BuildConfig.DEBUG) block whose variable is null in release; a listener reference from an uninitialized field.
Related errors
- Executor service must not be null.
- Memory cache must not be null.
- Transformer must not be null.
- RequestHandler must not be null.
- Downloader already set.
AI-assisted analysis of didi/DoKit@626827cddb (2026-08-14).
Data as JSON: /api/errors/f4d76d4039112422.
Report an issue: GitHub.