didi/DoKit · error · IllegalArgumentException

appWidgetIds must not be null.

Error message

appWidgetIds must not be null.

What it means

Thrown by RequestCreator.into(RemoteViews, int, int[]) when the appWidgetIds array is null. AppWidgetAction uses the ID array to push the updated bitmap to every instantiated widget via AppWidgetManager, so the array is mandatory. The library validates it before building the request and throws IllegalArgumentException on null.

Source

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

        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) {
        long started = System.nanoTime();

        if (remoteViews == null) {
            throw new IllegalArgumentException("remoteViews must not be null.");
        }
        if (appWidgetIds == null) {
            throw new IllegalArgumentException("appWidgetIds must not be null.");
        }
        if (deferred) {
            throw new IllegalStateException("Fit cannot be used with remote views.");
        }
        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 AppWidgetAction(picasso, request, remoteViews, viewId, appWidgetIds, memoryPolicy,
                        networkPolicy, key, tag, errorResId);

        performRemoteViewInto(action);
    }

View on GitHub (pinned to 626827cddb)

Solutions

  1. Pass the real ID array: appWidgetManager.getAppWidgetIds(new ComponentName(context, MyWidgetProvider.class)).
  2. In AppWidgetProvider.onUpdate, forward the appWidgetIds parameter already provided by the system (it is never null there).
  3. If updating one instance, wrap the single ID: new int[]{ appWidgetId }.

Example fix

// before
picasso.load(url).into(views, R.id.widget_icon, null);

// after
int[] ids = appWidgetManager.getAppWidgetIds(new ComponentName(context, MyWidgetProvider.class));
picasso.load(url).into(views, R.id.widget_icon, ids);
Defensive patterns

Strategy: validation

Validate before calling

int[] ids = (appWidgetIds != null) ? appWidgetIds
        : appWidgetManager.getAppWidgetIds(new ComponentName(context, MyProvider.class));
picasso.load(url).into(views, viewId, ids);

Prevention

When it happens

Trigger: Calling into(remoteViews, viewId, null); passing an int[] that came from an AppWidgetManager call whose result was stored in a nullable field; forwarding a parameter that an over-eager nullability annotation did not enforce.

Common situations: Forgetting to obtain ids from appWidgetManager.getAppWidgetIds(componentName); handling a single-widget case by skipping the ID lookup; onUpdate() plumbing where the ids argument is dropped.

Related errors


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