didi/DoKit · error · IllegalArgumentException
Cannot use placeholder or error drawables with remote views.
Error message
Cannot use placeholder or error drawables with remote views.
What it means
Thrown by RequestCreator.into(RemoteViews, int, int, Notification) when the request has a placeholder Drawable, placeholder resource, or error Drawable set. RemoteViews are rendered in another process (SystemUI), which cannot deserialize arbitrary in-process Drawable instances; only resource IDs (such as the permitted errorResId) can travel across the RemoteViews boundary. The library therefore rejects drawable-based placeholders/errors before creating the action.
Source
Thrown at Android/dokit/src/main/java/com/didichuxing/doraemonkit/picasso/RequestCreator.java:568
/**
* Asynchronously fulfills the request into the specified {@link RemoteViews} object with the
* given {@code viewId}. This is used for loading bitmaps into a {@link Notification}.
*/
public void into(RemoteViews remoteViews, int viewId, int notificationId,
Notification notification) {
long started = System.nanoTime();
if (remoteViews == null) {
throw new IllegalArgumentException("RemoteViews must not be null.");
}
if (notification == null) {
throw new IllegalArgumentException("Notification must not be null.");
}
if (deferred) {
throw new IllegalStateException("Fit cannot be used with RemoteViews.");
}
if (placeholderDrawable != null || placeholderResId != 0 || errorDrawable != null) {
throw new IllegalArgumentException(
"Cannot use placeholder or error drawables with remote views.");
}
Request request = createRequest(started);
String key = createKey(request, new StringBuilder()); // Non-main thread needs own builder.
RemoteViewsAction action =
new NotificationAction(picasso, request, remoteViews, viewId, notificationId, notification,
memoryPolicy, networkPolicy, key, tag, errorResId);
performRemoteViewInto(action);
}
/**
* Asynchronously fulfills the request into the specified {@link RemoteViews} object with the
* given {@code viewId}. This is used for loading bitmaps into all instances of a widget.
*/
public void into(RemoteViews remoteViews, int viewId, int[] appWidgetIds) {View on GitHub (pinned to 626827cddb)
Solutions
- Remove .placeholder(...) and .error(Drawable) calls from the request used for RemoteViews/notification loads.
- If an error image is needed, use .error(int errorResId) — the resource-ID form is explicitly passed through to NotificationAction and is allowed.
- Extract the RemoteViews request construction into its own helper so UI placeholders are not accidentally applied.
Example fix
// before
picasso.load(url)
.placeholder(R.id.progress) // or a Drawable
.error(errorDrawable)
.into(remoteViews, R.id.icon, notifId, notification);
// after
picasso.load(url)
.error(R.drawable.ic_notification_error) // resource ID form is allowed
.into(remoteViews, R.id.icon, notifId, notification); Defensive patterns
Strategy: validation
Validate before calling
// Build notification requests without drawable placeholders RequestCreator rc = picasso.load(url).error(R.drawable.ic_notif_error); // do NOT call rc.placeholder(drawable/resId) or rc.error(Drawable) rc.into(remoteViews, viewId, notifId, notification);
Try / catch
Not applicable — deterministic precondition violation; correct the request construction instead of catching.
Prevention
- Keep a dedicated builder for RemoteViews loads that only sets errorResId.
- Avoid global request customizers that inject placeholders into every request.
- Remember RemoteViews render cross-process: only resource IDs can be sent.
When it happens
Trigger: Calling .placeholder(Drawable), .placeholder(int resId), or .error(Drawable) on the builder and then into(remoteViews, viewId, notificationId, notification); the check fires for placeholderDrawable != null, placeholderResId != 0, or errorDrawable != null.
Common situations: Reusing a shared request configuration (with placeholders for lists) for notification icons; migrating an ImageView load that showed a spinner drawable while loading to a notification load.
Related errors
- Fit cannot be used with RemoteViews.
- Fit cannot be used with remote views.
- Priority already set.
- Error image already set.
- RemoteViews must not be null.
AI-assisted analysis of didi/DoKit@626827cddb (2026-08-14).
Data as JSON: /api/errors/830ddf79cdb28d2e.
Report an issue: GitHub.