{"record":{"id":"4ac53cbd7d4efc72","repo":"didi/DoKit","slug":"placeholder-resource-already-set","errorCode":null,"errorMessage":"Placeholder resource already set.","messagePattern":"Placeholder resource already set\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"Android/dokit/src/main/java/com/didichuxing/doraemonkit/picasso/RequestCreator.java","lineNumber":94,"sourceCode":"        this.picasso = picasso;\n        this.data = new Request.Builder(uri, resourceId, picasso.defaultBitmapConfig);\n    }\n\n    RequestCreator() {\n        this.picasso = null;\n        this.data = new Request.Builder(null, 0, null);\n    }\n\n    /**\n     * Explicitly opt-out to having a placeholder set when calling {@code into}.\n     * <p>\n     * By default, Picasso will either set a supplied placeholder or clear the target\n     * {@link ImageView} in order to ensure behavior in situations where views are recycled. This\n     * method will prevent that behavior and retain any already set image.\n     */\n    public RequestCreator noPlaceholder() {\n        if (placeholderResId != 0) {\n            throw new IllegalStateException(\"Placeholder resource already set.\");\n        }\n        if (placeholderDrawable != null) {\n            throw new IllegalStateException(\"Placeholder image already set.\");\n        }\n        setPlaceholder = false;\n        return this;\n    }\n\n    /**\n     * A placeholder drawable to be used while the image is being loaded. If the requested image is\n     * not immediately available in the memory cache then this resource will be set on the target\n     * {@link ImageView}.\n     */\n    public RequestCreator placeholder(int placeholderResId) {\n        if (!setPlaceholder) {\n            throw new IllegalStateException(\"Already explicitly declared as no placeholder.\");\n        }\n        if (placeholderResId == 0) {","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/didi/DoKit/blob/626827cddb2feb2f3aee87a52a064b4e5ca2bed4/Android/dokit/src/main/java/com/didichuxing/doraemonkit/picasso/RequestCreator.java#L76-L112","documentation":"Thrown by RequestCreator.noPlaceholder() when a placeholder resource id was already set via placeholder(int). noPlaceholder() is an exclusive alternative to any placeholder, so Picasso rejects mixing them on the same creator.","triggerScenarios":"Chaining .placeholder(R.drawable.ph).noPlaceholder() (or calling them in either order on the same RequestCreator).","commonSituations":"Shared helper applying a default placeholder, then request-specific code adding noPlaceholder(); copy-paste of two different samples into one chain; conditional logic where both branches execute.","solutions":["Choose either a placeholder or noPlaceholder() per request — never both.","Make placeholder presence a single decision point (parameter of your loader helper).","If a default placeholder was applied, build a fresh request without it instead of calling noPlaceholder()."],"exampleFix":"// before\nRequestCreator c = picasso.load(url).placeholder(R.drawable.ph);\nc.noPlaceholder(); // throws\n\n// after\nRequestCreator c = picasso.load(url).placeholder(R.drawable.ph); // keep placeholder\n// or\nRequestCreator c = picasso.load(url).noPlaceholder(); // no placeholder at all","handlingStrategy":"validation","validationCode":"// Single decision point in your helper\nRequestCreator c = picasso.load(url);\nif (placeholderResId != 0) c.placeholder(placeholderResId); else c.noPlaceholder();","typeGuard":null,"tryCatchPattern":null,"preventionTips":["placeholder(...) and noPlaceholder() are mutually exclusive per request.","Avoid applying default placeholders in shared code that later calls noPlaceholder()."],"tags":["android","picasso","builder","state-conflict","placeholder"],"backgroundTag":null,"analyzedSha":"626827cddb2feb2f3aee87a52a064b4e5ca2bed4","analyzedAt":"2026-08-14T12:45:58.758Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}