{"record":{"id":"8ba976ce702374cc","repo":"didi/DoKit","slug":"appwidgetids-must-not-be-null","errorCode":null,"errorMessage":"appWidgetIds must not be null.","messagePattern":"appWidgetIds must not be null\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"Android/dokit/src/main/java/com/didichuxing/doraemonkit/picasso/RequestCreator.java","lineNumber":593,"sourceCode":"        RemoteViewsAction action =\n                new NotificationAction(picasso, request, remoteViews, viewId, notificationId, notification,\n                        memoryPolicy, networkPolicy, key, tag, errorResId);\n\n        performRemoteViewInto(action);\n    }\n\n    /**\n     * Asynchronously fulfills the request into the specified {@link RemoteViews} object with the\n     * given {@code viewId}. This is used for loading bitmaps into all instances of a widget.\n     */\n    public void into(RemoteViews remoteViews, int viewId, int[] appWidgetIds) {\n        long started = System.nanoTime();\n\n        if (remoteViews == null) {\n            throw new IllegalArgumentException(\"remoteViews must not be null.\");\n        }\n        if (appWidgetIds == null) {\n            throw new IllegalArgumentException(\"appWidgetIds must not be null.\");\n        }\n        if (deferred) {\n            throw new IllegalStateException(\"Fit cannot be used with remote views.\");\n        }\n        if (placeholderDrawable != null || placeholderResId != 0 || errorDrawable != null) {\n            throw new IllegalArgumentException(\n                    \"Cannot use placeholder or error drawables with remote views.\");\n        }\n\n        Request request = createRequest(started);\n        String key = createKey(request, new StringBuilder()); // Non-main thread needs own builder.\n\n        RemoteViewsAction action =\n                new AppWidgetAction(picasso, request, remoteViews, viewId, appWidgetIds, memoryPolicy,\n                        networkPolicy, key, tag, errorResId);\n\n        performRemoteViewInto(action);\n    }","sourceCodeStart":575,"sourceCodeEnd":611,"githubUrl":"https://github.com/didi/DoKit/blob/626827cddb2feb2f3aee87a52a064b4e5ca2bed4/Android/dokit/src/main/java/com/didichuxing/doraemonkit/picasso/RequestCreator.java#L575-L611","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Pass the real ID array: appWidgetManager.getAppWidgetIds(new ComponentName(context, MyWidgetProvider.class)).","In AppWidgetProvider.onUpdate, forward the appWidgetIds parameter already provided by the system (it is never null there).","If updating one instance, wrap the single ID: new int[]{ appWidgetId }."],"exampleFix":"// before\npicasso.load(url).into(views, R.id.widget_icon, null);\n\n// after\nint[] ids = appWidgetManager.getAppWidgetIds(new ComponentName(context, MyWidgetProvider.class));\npicasso.load(url).into(views, R.id.widget_icon, ids);","handlingStrategy":"validation","validationCode":"int[] ids = (appWidgetIds != null) ? appWidgetIds\n        : appWidgetManager.getAppWidgetIds(new ComponentName(context, MyProvider.class));\npicasso.load(url).into(views, viewId, ids);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always source widget IDs from onUpdate's appWidgetIds or AppWidgetManager.getAppWidgetIds.","Wrap single updates as new int[]{id} rather than passing null.","Annotate your wrapper parameters @NonNull int[] to surface bad call sites."],"tags":["android","picasso","appwidget","null-argument"],"backgroundTag":null,"analyzedSha":"626827cddb2feb2f3aee87a52a064b4e5ca2bed4","analyzedAt":"2026-08-14T12:45:58.758Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}