{"record":{"id":"283375d05282e80c","repo":"didi/DoKit","slug":"notification-must-not-be-null","errorCode":null,"errorMessage":"Notification must not be null.","messagePattern":"Notification 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":562,"sourceCode":"        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);\n\n        performRemoteViewInto(action);\n    }","sourceCodeStart":544,"sourceCodeEnd":580,"githubUrl":"https://github.com/didi/DoKit/blob/626827cddb2feb2f3aee87a52a064b4e5ca2bed4/Android/dokit/src/main/java/com/didichuxing/doraemonkit/picasso/RequestCreator.java#L544-L580","documentation":"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.","triggerScenarios":"Calling .into(remoteViews, viewId, notifId, null), or passing a Notification variable that was never built/assigned before the call.","commonSituations":"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.","solutions":["Build the Notification first and pass it: Notification n = builder.build(); picasso.load(url).into(rv, viewId, id, n);","Ensure the notificationId passed matches the id you used with NotificationManager.notify, so Picasso's repost works","If the notification object is unavailable at that point, restructure so into() is called after the notification exists"],"exampleFix":"// before\npicasso.load(url).into(rv, R.id.notif_img, 1001, null); // throws \"Notification must not be null.\"\n\n// after\nNotification n = builder.build();\npicasso.load(url).into(rv, R.id.notif_img, 1001, n);","handlingStrategy":"validation","validationCode":"Notification n = builder.build(); // build BEFORE the load call\nif (n != null && rv != null) {\n    picasso.load(url).into(rv, R.id.notif_img, NOTIF_ID, n);\n}","typeGuard":"static Notification requireNotification(Notification n) {\n    if (n == null) throw new IllegalArgumentException(\"Notification required\");\n    return n;\n}","tryCatchPattern":null,"preventionTips":["Always call NotificationCompat.Builder.build() before passing the notification into Picasso","Keep the notificationId passed to into() identical to the id used with NotificationManager.notify so Picasso's repost targets the right notification","Order operations: build notification -> start image load; never the reverse"],"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-15T17:31:12.345Z"}