didi/DoKit · error · IllegalArgumentException

RemoteViews must not be null.

Error message

RemoteViews must not be null.

What it means

Thrown by RequestCreator.into(RemoteViews, int, int, Notification) when the RemoteViews argument is null. This overload loads a bitmap into a RemoteViews layout (typically a notification's large icon), which requires an actual RemoteViews object to apply the bitmap to; Picasso validates before doing anything else and throws IllegalArgumentException.

Source

Thrown at Android/dokit/src/main/java/com/didichuxing/doraemonkit/picasso/RequestCreator.java:559

        target.onPrepareLoad(setPlaceholder ? getPlaceholderDrawable() : null);

        Action action =
                new TargetAction(picasso, target, request, memoryPolicy, networkPolicy, errorDrawable,
                        requestKey, tag, errorResId);
        picasso.enqueueAndSubmit(action);
    }

    /**
     * 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);

View on GitHub (pinned to 626827cddb)

Solutions

  1. Build the RemoteViews explicitly and pass that instance: new RemoteViews(pkg, R.layout.notif) with setImageViewResource placeholder applied
  2. Use the value from a built notification: Notification n = builder.build(); then pass n.contentView only after asserting it is non-null
  3. Guard: if (remoteViews != null) picasso.load(url).into(remoteViews, viewId, id, n); else fall back to a plain setLargeIcon bitmap

Example fix

// before
Notification n = builder.build();
picasso.load(url).into(n.contentView, R.id.notif_img, 1001, n); // contentView may be null

// after
RemoteViews rv = new RemoteViews(pkg, R.layout.notification_layout);
rv.setImageViewResource(R.id.notif_img, R.drawable.placeholder);
picasso.load(url).into(rv, R.id.notif_img, 1001, builder.build());
Defensive patterns

Strategy: validation

Validate before calling

RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.notification_layout);
rv.setImageViewResource(R.id.notif_img, R.drawable.placeholder);
Notification n = builder.build();
if (rv != null && n != null) {
    picasso.load(url).into(rv, R.id.notif_img, NOTIF_ID, n);
}

Type guard

static RemoteViews requireRemoteViews(RemoteViews rv) {
    if (rv == null) throw new IllegalArgumentException("RemoteViews required");
    return rv;
}

Prevention

When it happens

Trigger: Calling .into(null, viewId, notifId, notification) — e.g. passing notification.contentView directly, which can be null for notifications built solely with NotificationCompat decorative styles on some paths.

Common situations: Using notification.contentView instead of builder.build().contentView; constructing RemoteViews conditionally (only on older API levels) and forgetting the null path; test code building Notification objects without a content view.

Related errors


AI-assisted analysis of didi/DoKit@626827cddb (2026-08-14). Data as JSON: /api/errors/cf08be02e17fb882. Report an issue: GitHub.