{"record":{"id":"cf08be02e17fb882","repo":"didi/DoKit","slug":"remoteviews-must-not-be-null","errorCode":null,"errorMessage":"RemoteViews must not be null.","messagePattern":"RemoteViews must not be null\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"Android/dokit/src/main/java/com/didichuxing/doraemonkit/picasso/RequestCreator.java","lineNumber":559,"sourceCode":"\n        target.onPrepareLoad(setPlaceholder ? getPlaceholderDrawable() : null);\n\n        Action action =\n                new TargetAction(picasso, target, request, memoryPolicy, networkPolicy, errorDrawable,\n                        requestKey, tag, errorResId);\n        picasso.enqueueAndSubmit(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 a {@link Notification}.\n     */\n    public void into(RemoteViews remoteViews, int viewId, int notificationId,\n                     Notification notification) {\n        long started = System.nanoTime();\n\n        if (remoteViews == null) {\n            throw new IllegalArgumentException(\"RemoteViews must not be null.\");\n        }\n        if (notification == null) {\n            throw new IllegalArgumentException(\"Notification must not be null.\");\n        }\n        if (deferred) {\n            throw new IllegalStateException(\"Fit cannot be used with RemoteViews.\");\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 NotificationAction(picasso, request, remoteViews, viewId, notificationId, notification,\n                        memoryPolicy, networkPolicy, key, tag, errorResId);","sourceCodeStart":541,"sourceCodeEnd":577,"githubUrl":"https://github.com/didi/DoKit/blob/626827cddb2feb2f3aee87a52a064b4e5ca2bed4/Android/dokit/src/main/java/com/didichuxing/doraemonkit/picasso/RequestCreator.java#L541-L577","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Build the RemoteViews explicitly and pass that instance: new RemoteViews(pkg, R.layout.notif) with setImageViewResource placeholder applied","Use the value from a built notification: Notification n = builder.build(); then pass n.contentView only after asserting it is non-null","Guard: if (remoteViews != null) picasso.load(url).into(remoteViews, viewId, id, n); else fall back to a plain setLargeIcon bitmap"],"exampleFix":"// before\nNotification n = builder.build();\npicasso.load(url).into(n.contentView, R.id.notif_img, 1001, n); // contentView may be null\n\n// after\nRemoteViews rv = new RemoteViews(pkg, R.layout.notification_layout);\nrv.setImageViewResource(R.id.notif_img, R.drawable.placeholder);\npicasso.load(url).into(rv, R.id.notif_img, 1001, builder.build());","handlingStrategy":"validation","validationCode":"RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.notification_layout);\nrv.setImageViewResource(R.id.notif_img, R.drawable.placeholder);\nNotification n = builder.build();\nif (rv != null && n != null) {\n    picasso.load(url).into(rv, R.id.notif_img, NOTIF_ID, n);\n}","typeGuard":"static RemoteViews requireRemoteViews(RemoteViews rv) {\n    if (rv == null) throw new IllegalArgumentException(\"RemoteViews required\");\n    return rv;\n}","tryCatchPattern":null,"preventionTips":["Construct RemoteViews explicitly instead of relying on notification.contentView being non-null","Apply a placeholder via rv.setImageViewResource before handing it to Picasso (the API forbids placeholder/error drawables here)","Run into(RemoteViews,...) on a background thread; it is one of the few into() variants allowed off the main thread"],"tags":["picasso","dokit","android","image-loading","remoteviews","notifications","null-safety"],"backgroundTag":null,"analyzedSha":"626827cddb2feb2f3aee87a52a064b4e5ca2bed4","analyzedAt":"2026-08-14T12:45:58.758Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}