PhilJay/MPAndroidChart · error · RuntimeException
Fill-drawables not (yet) supported below API level 18, this
Error message
Fill-drawables not (yet) supported below API level 18, this code was run on API level {Utils.getSDKInt()}. What it means
Thrown by Fill.ensureClipPathSupported() when a Drawable-based fill is requested on API < 18. It is the same guard as LineRadarRenderer's, centralized in the Fill utility: isClipPathSupported() returns Utils.getSDKInt() >= 18 and ensureClipPathSupported() throws if not. The DRAWABLE branch of Fill performs a Canvas.clipPath which needs the modern canvas behavior.
Source
Thrown at MPChartLib/src/main/java/com/github/mikephil/charting/utils/Fill.java:338
clipRect == null ? c.getHeight() : (int) clipRect.bottom);
mDrawable.draw(c);
c.restoreToCount(save);
}
break;
}
}
private boolean isClipPathSupported()
{
return Utils.getSDKInt() >= 18;
}
private void ensureClipPathSupported()
{
if (Utils.getSDKInt() < 18)
{
throw new RuntimeException("Fill-drawables not (yet) supported below API level 18, " +
"this code was run on API level " + Utils.getSDKInt() + ".");
}
}
}
View on GitHub (pinned to 9c7275a059)
Solutions
- Use a color-based Fill on API < 18 and reserve Drawable fills for API >= 18.
- Raise the app's minSdkVersion to 18 if drawable fills are required everywhere.
- Check fill.isClipPathSupported() (or Utils.getSDKInt() >= 18) before assigning a Drawable fill.
- Provide a fallback color in your chart-styling code for legacy devices.
Example fix
// before
Fill fill = new Fill(myDrawable);
fill.fillPath(path, paint, canvas); // throws on API < 18
// after
Fill fill = (Utils.getSDKInt() >= 18)
? new Fill(myDrawable)
: new Fill(Color.argb(80, 0, 0, 0));
fill.fillPath(path, paint, canvas); Defensive patterns
Strategy: validation
Validate before calling
if (Utils.getSDKInt() >= 18) {
fill = new Fill(myDrawable);
} else {
fill = new Fill(Color.argb(80, 0, 0, 0));
} Type guard
boolean supportsClipPath() {
return Utils.getSDKInt() >= 18;
} Prevention
- Use color or shader fills on API < 18.
- Centralize API-level gating in your chart-styling layer.
- Test fills across the lowest API in your support matrix.
When it happens
Trigger: Configuring a Fill with Type.DRAWABLE or a Drawable and rendering on a device/emulator below API 18. Calling fill.fillPath(...) on a low-API runtime when mDrawable != null.
Common situations: Supporting old Android versions; using bitmap/gradient drawables for chart area fills; emulator-based testing on older images; library consumers unaware of the API-18 requirement.
Related errors
AI-assisted analysis of PhilJay/MPAndroidChart@9c7275a059 (2026-08-14).
Data as JSON: /api/errors/ae44399420a6a696.
Report an issue: GitHub.