didi/DoKit · error · IllegalStateException
Unrecognized type of request: " + request
Error message
Unrecognized type of request: " + request
What it means
BitmapHunter's static ERRORING_HANDLER is used as the request handler when forRequest() finds no registered RequestHandler whose canHandleRequest(Request) returns true. Its load() always throws IllegalStateException('Unrecognized type of request: ' + request), so the exception surfaces on the hunter thread (or via the request pipeline) with the full request dump. It is Picasso's way of turning 'no handler for this URI/data type' into an explicit, diagnosable failure instead of a silent no-op.
Source
Thrown at Android/dokit/src/main/java/com/didichuxing/doraemonkit/picasso/BitmapHunter.java:66
* well as potential OOMs. Shamelessly stolen from Volley.
*/
private static final Object DECODE_LOCK = new Object();
private static final ThreadLocal<StringBuilder> NAME_BUILDER = new ThreadLocal<StringBuilder>() {
@Override protected StringBuilder initialValue() {
return new StringBuilder(Utils.THREAD_PREFIX);
}
};
private static final AtomicInteger SEQUENCE_GENERATOR = new AtomicInteger();
private static final RequestHandler ERRORING_HANDLER = new RequestHandler() {
@Override public boolean canHandleRequest(Request data) {
return true;
}
@Override public Result load(Request request, int networkPolicy) throws IOException {
throw new IllegalStateException("Unrecognized type of request: " + request);
}
};
final int sequence;
final DokitPicasso picasso;
final Dispatcher dispatcher;
final Cache cache;
final Stats stats;
final String key;
final Request data;
final int memoryPolicy;
int networkPolicy;
final RequestHandler requestHandler;
Action action;
List<Action> actions;
Bitmap result;
Future<?> future;View on GitHub (pinned to 626827cddb)
Solutions
- Inspect the message's request dump: check the uri scheme and resourceId fields to see why nothing matched
- For custom schemes, register a handler: new DokitPicasso.Builder(context).addRequestHandler(new MySchemeHandler()).build() with canHandleRequest returning true for that scheme
- Fix the URI itself, e.g. use Uri.fromFile(file) or a well-formed https:// URL
- If you meant a resource, use load(R.drawable.x) rather than load("res://...") style strings
Example fix
// before
DokitPicasso.with(context).load(Uri.parse("myapp://avatar/42")).into(view);
// -> IllegalStateException: Unrecognized type of request
// after
class MyAppRequestHandler extends RequestHandler {
@Override public boolean canHandleRequest(Request data) {
return "myapp".equals(data.uri.getScheme());
}
@Override public Result load(Request request, int networkPolicy) throws IOException {
return new Result(decodeMyAppAsset(request.uri), Picasso.LoadedFrom.DISK);
}
}
DokitPicasso picasso = new DokitPicasso.Builder(context)
.addRequestHandler(new MyAppRequestHandler()).build();
picasso.load(Uri.parse("myapp://avatar/42")).into(view); Defensive patterns
Strategy: validation
Validate before calling
// Validate the URI against the schemes your handlers actually support before loading.
static boolean isLoadable(Uri uri) {
if (uri == null) return false;
String s = uri.getScheme();
return "http".equals(s) || "https".equals(s) || "file".equals(s)
|| "content".equals(s) || "android.resource".equals(s) || "myapp".equals(s);
}
if (isLoadable(uri)) picasso.load(uri).into(view); else view.setImageResource(placeholder); Try / catch
// The throw happens on a hunter/dispatch thread; surface it via the request callback instead:
picasso.load(uri)
.error(R.drawable.broken)
.into(view, new Callback() {
@Override public void onSuccess() {}
@Override public void onError(Exception e) {
if (e instanceof IllegalStateException
&& e.getMessage() != null && e.getMessage().contains("Unrecognized type of request")) {
Log.e(TAG, "No RequestHandler for " + uri, e);
}
}
}); Prevention
- Register a RequestHandler for every custom scheme your app loads
- Log the request dump from the message — the uri field shows exactly what failed to match
- Build URIs with Uri.parse on validated strings or Uri.fromFile for files
When it happens
Trigger: Calling picasso.load(uri) with a scheme no handler covers (custom scheme, malformed http URI, unknown content:// authority) while custom RequestHandlers added via Builder.addRequestHandler all return false from canHandleRequest; the ERRORING_HANDLER is also returned for requests that fail handler resolution before hunting starts.
Common situations: Loading a file path string that parses to a URI with no scheme; app-specific uri:// scheme with the custom handler forgotten or its canHandleRequest logic buggy; media store URIs on devices where the contacts/media handler does not match.
Related errors
- Invalid uri: <uri>
- Width must be positive number or 0.
- Height must be positive number or 0.
- At least one dimension has to be positive number.
- Center crop can not be used after calling centerInside
AI-assisted analysis of didi/DoKit@626827cddb (2026-08-14).
Data as JSON: /api/errors/f399a544c6ef2f5e.
Report an issue: GitHub.