{"record":{"id":"263bbaf0589a38ae","repo":"didi/DoKit","slug":"fit-cannot-be-used-with-get","errorCode":null,"errorMessage":"Fit cannot be used with get.","messagePattern":"Fit cannot be used with get\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"Android/dokit/src/main/java/com/didichuxing/doraemonkit/picasso/RequestCreator.java","lineNumber":405,"sourceCode":"     * Disable brief fade in of images loaded from the disk cache or network.\n     */\n    public RequestCreator noFade() {\n        noFade = true;\n        return this;\n    }\n\n    /**\n     * Synchronously fulfill this request. Must not be called from the main thread.\n     * <p>\n     * <em>Note</em>: The result of this operation is not cached in memory because the underlying\n     * {@link Cache} implementation is not guaranteed to be thread-safe.\n     */\n    public Bitmap get() throws IOException {\n        long started = System.nanoTime();\n        checkNotMain();\n\n        if (deferred) {\n            throw new IllegalStateException(\"Fit cannot be used with get.\");\n        }\n        if (!data.hasImage()) {\n            return null;\n        }\n\n        Request finalData = createRequest(started);\n        String key = createKey(finalData, new StringBuilder());\n\n        Action action = new GetAction(picasso, finalData, memoryPolicy, networkPolicy, tag, key);\n        return forRequest(picasso, picasso.dispatcher, picasso.cache, picasso.stats, action).hunt();\n    }\n\n    /**\n     * Asynchronously fulfills the request without a {@link ImageView} or {@link Target}. This is\n     * useful when you want to warm up the cache with an image.\n     * <p>\n     * <em>Note:</em> It is safe to invoke this method from any thread.\n     */","sourceCodeStart":387,"sourceCodeEnd":423,"githubUrl":"https://github.com/didi/DoKit/blob/626827cddb2feb2f3aee87a52a064b4e5ca2bed4/Android/dokit/src/main/java/com/didichuxing/doraemonkit/picasso/RequestCreator.java#L387-L423","documentation":"Thrown by RequestCreator.get() when the chain called fit(). fit() marks the request as deferred so it can wait for the target ImageView to be measured at layout time; get() is a synchronous, target-less API, so the two are fundamentally incompatible and Picasso throws IllegalStateException.","triggerScenarios":"Calling picasso.load(url).fit().get(), e.g. to prefetch/measure the bitmap synchronously on a background thread while reusing fit() from an into() chain.","commonSituations":"Copying an into(imageView) chain (which used fit()) into a background preheat method that calls get(); adapting widget/AppWidget code that needs the Bitmap directly; unit-test helpers that synchronously load via get().","solutions":["Remove fit() before get(), and specify explicit sizing instead: .resize(w, h).centerInside().get()","If the image is destined for an ImageView, use into(imageView) and keep fit()","For prefetching, drop fit() and use fetch(), or get() with resize() matching the view size"],"exampleFix":"// before\nBitmap bmp = picasso.load(url).fit().get(); // throws \"Fit cannot be used with get.\"\n\n// after\nBitmap bmp = picasso.load(url).resize(1080, 1920).centerInside().get();","handlingStrategy":"validation","validationCode":"RequestCreator rc = picasso.load(url);\nif (needSync) {\n    Bitmap bmp = rc.resize(width, height).centerInside().get(); // no fit()\n} else {\n    rc.fit().into(imageView);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember fit() is only legal with into(ImageView); get(), fetch(), and into(Target) all reject it","For synchronous loads, always supply explicit dimensions via resize()","Do not copy display chains into prefetch/sync helpers without removing fit()"],"tags":["picasso","dokit","android","image-loading","fit","synchronous"],"backgroundTag":null,"analyzedSha":"626827cddb2feb2f3aee87a52a064b4e5ca2bed4","analyzedAt":"2026-08-14T12:45:58.758Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}