didi/DoKit · error · IllegalArgumentException

Notification must not be null.

Error message

Notification must not be null.

What it means

Thrown by RequestCreator.into(RemoteViews, int, int, Notification) when the Notification argument is null. Picasso needs the Notification to re-apply (repost) it after the bitmap lands in the RemoteViews, so a null Notification makes the whole flow impossible and throws IllegalArgumentException.

Source

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

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

        performRemoteViewInto(action);
    }

View on GitHub (pinned to 626827cddb)

Solutions

  1. Build the Notification first and pass it: Notification n = builder.build(); picasso.load(url).into(rv, viewId, id, n);
  2. Ensure the notificationId passed matches the id you used with NotificationManager.notify, so Picasso's repost works
  3. If the notification object is unavailable at that point, restructure so into() is called after the notification exists

Example fix

// before
picasso.load(url).into(rv, R.id.notif_img, 1001, null); // throws "Notification must not be null."

// after
Notification n = builder.build();
picasso.load(url).into(rv, R.id.notif_img, 1001, n);
Defensive patterns

Strategy: validation

Validate before calling

Notification n = builder.build(); // build BEFORE the load call
if (n != null && rv != null) {
    picasso.load(url).into(rv, R.id.notif_img, NOTIF_ID, n);
}

Type guard

static Notification requireNotification(Notification n) {
    if (n == null) throw new IllegalArgumentException("Notification required");
    return n;
}

Prevention

When it happens

Trigger: Calling .into(remoteViews, viewId, notifId, null), or passing a Notification variable that was never built/assigned before the call.

Common situations: Loading the notification image before builder.build() runs; refactoring code so the Notification is constructed later; passing a Notification field from a background thread where it was not yet posted.

Related errors


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