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 LineRadarRenderer when a Fill is configured to use a Drawable but the runtime API level is below 18 (Android 4.3). Clip-path + drawable drawing relies on Canvas.clipPath hardware acceleration behavior that is unreliable before API 18, so the renderer refuses to draw rather than render incorrectly. The actual SDK level is interpolated into the message.
Source
Thrown at MPChartLib/src/main/java/com/github/mikephil/charting/renderer/LineRadarRenderer.java:43
* @param filledPath
* @param drawable
*/
protected void drawFilledPath(Canvas c, Path filledPath, Drawable drawable) {
if (clipPathSupported()) {
int save = c.save();
c.clipPath(filledPath);
drawable.setBounds((int) mViewPortHandler.contentLeft(),
(int) mViewPortHandler.contentTop(),
(int) mViewPortHandler.contentRight(),
(int) mViewPortHandler.contentBottom());
drawable.draw(c);
c.restoreToCount(save);
} else {
throw new RuntimeException("Fill-drawables not (yet) supported below API level 18, " +
"this code was run on API level " + Utils.getSDKInt() + ".");
}
}
/**
* Draws the provided path in filled mode with the provided color and alpha.
* Special thanks to Angelo Suzuki (https://github.com/tinsukE) for this.
*
* @param c
* @param filledPath
* @param fillColor
* @param fillAlpha
*/
protected void drawFilledPath(Canvas c, Path filledPath, int fillColor, int fillAlpha) {
int color = (fillAlpha << 24) | (fillColor & 0xffffff);
if (clipPathSupported()) {View on GitHub (pinned to 9c7275a059)
Solutions
- Raise minSdkVersion to 18 (or higher) if your device matrix allows it.
- Gate drawable fills at runtime: if (Utils.getSDKInt() >= 18) set.setFillDrawable(d); else use a solid color Fill.
- Use Fill.Type.COLOR (solid color) or a gradient shader instead of a Drawable for pre-18 devices.
- Filter the feature in build flavors so legacy builds never configure drawable fills.
Example fix
// before
Fill fill = new Fill(d -> drawable);
lineDataSet.setFill(drawableFill); // crashes below API 18
// after
Fill fill;
if (Utils.getSDKInt() >= 18) {
fill = new Fill(myDrawable);
} else {
fill = new Fill(Color.parseColor("#33000000"));
}
lineDataSet.setFill(fill); Defensive patterns
Strategy: validation
Validate before calling
if (Utils.getSDKInt() >= 18) {
lineDataSet.setFillDrawable(myDrawable);
} else {
lineDataSet.setFillColor(fallbackColor);
} Type guard
boolean supportsDrawableFill() {
return Utils.getSDKInt() >= 18;
} Prevention
- Gate drawable fills behind an API-level check.
- Keep a solid-color Fill fallback for legacy devices.
- Set minSdkVersion appropriately or exclude drawable fills via build flavors.
When it happens
Trigger: Setting a line/radar Fill with setFillDrawable(...) or Fill.setType(Fill.Type.DRAWABLE) and running the app on a device/emulator below Android 4.3 (API 17 or lower). Running instrumentation tests on a low-API emulator.
Common situations: Shipping to legacy devices; minSdkVersion < 18 while using drawable fills; CI matrix that includes older emulator images; using gradient/bitmap drawables for area fills without gating on API level.
Related errors
AI-assisted analysis of PhilJay/MPAndroidChart@9c7275a059 (2026-08-14).
Data as JSON: /api/errors/118bc493d56096e6.
Report an issue: GitHub.