{"record":{"id":"f954d778deb2162b","repo":"didi/DoKit","slug":"remoteviews-must-not-be-null-f954d7","errorCode":null,"errorMessage":"remoteViews must not be null.","messagePattern":"remoteViews 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":590,"sourceCode":"        Request request = createRequest(started);\n        String key = createKey(request, new StringBuilder()); // Non-main thread needs own builder.\n\n        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);","sourceCodeStart":572,"sourceCodeEnd":608,"githubUrl":"https://github.com/didi/DoKit/blob/626827cddb2feb2f3aee87a52a064b4e5ca2bed4/Android/dokit/src/main/java/com/didichuxing/doraemonkit/picasso/RequestCreator.java#L572-L608","documentation":"Thrown by RequestCreator.into(RemoteViews, int, int[]) (the app-widget variant) when the remoteViews argument is null. The action (AppWidgetAction) needs a concrete RemoteViews instance to apply the loaded bitmap into every widget instance, so a null one is rejected immediately with an IllegalArgumentException. This is a plain argument-contract failure, not a state conflict.","triggerScenarios":"Calling into(null, viewId, appWidgetIds), or passing a RemoteViews variable that was never constructed / was nulled after a failed build, into the widget variant of into().","commonSituations":"Building RemoteViews conditionally (e.g. only for certain widget sizes) and passing the variable unconditionally; copy-paste from the notification variant where the wrong local variable is passed; widget provider code paths where the layout inflation was skipped.","solutions":["Construct the RemoteViews(context.getPackageName(), R.layout.widget_layout) before calling into().","Guard the call: only invoke into() when the RemoteViews was successfully created.","Check that the widget layout resource exists and the correct package name is used, since RemoteViews construction itself throws on bad resources."],"exampleFix":"// before\nRemoteViews views = maybeBuildViews(); // may return null\npicasso.load(url).into(views, R.id.widget_icon, appWidgetIds);\n\n// after\nRemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_layout);\npicasso.load(url).into(views, R.id.widget_icon, appWidgetIds);","handlingStrategy":"validation","validationCode":"if (remoteViews == null) {\n    remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget_layout);\n}\npicasso.load(url).into(remoteViews, viewId, appWidgetIds);","typeGuard":"private boolean isValidRemoteViewsTarget(RemoteViews rv, int[] ids) {\n    return rv != null && ids != null && ids.length > 0;\n}","tryCatchPattern":null,"preventionTips":["Always construct RemoteViews with (packageName, layoutRes) right before the load.","Make RemoteViews parameters @NonNull in your own wrappers so nullability is explicit.","Static-check widget update code paths for nullable locals."],"tags":["android","picasso","remoteviews","appwidget","null-argument"],"backgroundTag":null,"analyzedSha":"626827cddb2feb2f3aee87a52a064b4e5ca2bed4","analyzedAt":"2026-08-14T12:45:58.758Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}