didi/DoKit · error · IllegalArgumentException
Use setStrokeWidth method of Paint class to specify line siz
Error message
Use setStrokeWidth method of Paint class to specify line size. Do not provider SizeProvider if you set PaintProvider.
What it means
Thrown by FlexibleDividerDecoration.Builder.checkBuilderParams() when both a PaintProvider and a SizeProvider are set. SizeProvider controls divider thickness, but a supplied Paint already defines thickness via paint.setStrokeWidth, so configuring both is contradictory and rejected at build() time.
Source
Thrown at Android/dokit/src/main/java/com/didichuxing/doraemonkit/kit/toolpanel/decoration/FlexibleDividerDecoration.java:549
public T showLastDivider() {
mShowLastDivider = true;
return (T) this;
}
public T positionInsideItem(boolean positionInsideItem) {
mPositionInsideItem = positionInsideItem;
return (T) this;
}
protected void checkBuilderParams() {
if (mPaintProvider != null) {
if (mColorProvider != null) {
throw new IllegalArgumentException(
"Use setColor method of Paint class to specify line color. Do not provider ColorProvider if you set PaintProvider.");
}
if (mSizeProvider != null) {
throw new IllegalArgumentException(
"Use setStrokeWidth method of Paint class to specify line size. Do not provider SizeProvider if you set PaintProvider.");
}
}
}
}
}View on GitHub (pinned to 626827cddb)
Solutions
- Remove the SizeProvider/size() call and set thickness on the Paint: paint.setStrokeWidth(dp) before supplying the PaintProvider
- Keep SizeProvider and drop PaintProvider if you only need a custom size
- Set stroke width per-item inside the PaintProvider when sizes vary by position
Example fix
// before
builder.paintProvider(() -> paint)
.size(4) // throws in checkBuilderParams()
.build();
// after
paint.setStrokeWidth(4);
builder.paintProvider(() -> paint)
.build(); Defensive patterns
Strategy: validation
Validate before calling
if (paintProvider != null) {
// ensure no size()/sizeProvider() was set: set stroke width on the Paint itself
paint.setStrokeWidth(dpToPx);
}
builder.paintProvider(() -> paint).build(); // no SizeProvider set Prevention
- Set divider thickness via paint.setStrokeWidth when using a PaintProvider
- When migrating a builder from size() to paintProvider(), remove the old size() call in the same change
When it happens
Trigger: Calling builder.paintProvider(...) and builder.size(...) (or sizeProvider(...)) on the same divider builder, then build(); commonly hit when a shared divider builder is reused and a size was set earlier in the chain.
Common situations: Incremental migration from simple color/size configuration to a full PaintProvider without cleaning up prior size() calls; builders assembled from helper methods that each add their own provider
Related errors
- Use setColor method of Paint class to specify line color. Do
- Set circle needn't set radius.
- invalid shadow size
- failed to get size
- failed to get size
AI-assisted analysis of didi/DoKit@626827cddb (2026-08-14).
Data as JSON: /api/errors/3dd736f6ad324862.
Report an issue: GitHub.