{"record":{"id":"0d035aafb8bf1e5f","repo":"didi/DoKit","slug":"center-inside-requires-calling-resize-with-positiv","errorCode":null,"errorMessage":"Center inside requires calling resize with positive width and height.","messagePattern":"Center inside requires calling resize with positive width and height\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"Android/dokit/src/main/java/com/didichuxing/doraemonkit/picasso/Request.java","lineNumber":464,"sourceCode":"        throw new IllegalArgumentException(\"Transformation list must not be null.\");\n      }\n      for (int i = 0, size = transformations.size(); i < size; i++) {\n        transform(transformations.get(i));\n      }\n      return this;\n    }\n\n    /** Create the immutable {@link Request} object. */\n    public Request build() {\n      if (centerInside && centerCrop) {\n        throw new IllegalStateException(\"Center crop and center inside can not be used together.\");\n      }\n      if (centerCrop && (targetWidth == 0 && targetHeight == 0)) {\n        throw new IllegalStateException(\n            \"Center crop requires calling resize with positive width and height.\");\n      }\n      if (centerInside && (targetWidth == 0 && targetHeight == 0)) {\n        throw new IllegalStateException(\n            \"Center inside requires calling resize with positive width and height.\");\n      }\n      if (priority == null) {\n        priority = Priority.NORMAL;\n      }\n      return new Request(uri, resourceId, stableKey, transformations, targetWidth, targetHeight,\n          centerCrop, centerInside, onlyScaleDown, rotationDegrees, rotationPivotX, rotationPivotY,\n          hasRotationPivot, config, priority);\n    }\n  }\n}\n","sourceCodeStart":446,"sourceCodeEnd":476,"githubUrl":"https://github.com/didi/DoKit/blob/626827cddb2feb2f3aee87a52a064b4e5ca2bed4/Android/dokit/src/main/java/com/didichuxing/doraemonkit/picasso/Request.java#L446-L476","documentation":"Thrown by Request.Builder.build() when centerInside was set but no resize target exists (targetWidth == 0 && targetHeight == 0). Center-inside scales an image down to fit inside bounds; with no bounds the transformation has nothing to fit into, so build() rejects it.","triggerScenarios":"Chaining .centerInside() with no .resize(w, h) (or after clearResize()) and then building/into().","commonSituations":"Request built before the target view is measured so resize values ended up 0/omitted; removing a resize call during refactoring while keeping centerInside; assuming centerInside() alone constrains the image.","solutions":["Call .resize(w, h) with at least one positive dimension before .centerInside().","Use .fit().centerInside() to size to the view at request time.","Log/validate dimensions at request-build time when they come from view measurements."],"exampleFix":"// before\npicasso.load(url).centerInside().into(imageView);\n\n// after\npicasso.load(url).fit().centerInside().into(imageView); // or .resize(600, 400).centerInside()","handlingStrategy":"validation","validationCode":"if (targetWidth > 0 || targetHeight > 0) { builder.resize(w, h).centerInside(); } else { builder.fit().centerInside(); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pair every centerInside() with resize() or fit().","Load after layout when dimensions come from a view."],"tags":["android","picasso","image-loading","builder","ordering"],"backgroundTag":null,"analyzedSha":"626827cddb2feb2f3aee87a52a064b4e5ca2bed4","analyzedAt":"2026-08-14T12:45:58.758Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}