MuntashirAkon/AppManager · error · RuntimeException
Unexpected char '" + c + "'.
Error message
Unexpected char '" + c + "'.
What it means
ParserHelper (SVG path/number parser) throws RuntimeException("Unexpected char '<c>'.") when parseFloat encounters a character that cannot start or continue a numeric value. It is an unchecked parsing failure for malformed SVG numeric data.
Solutions
- Validate/normalize SVG path data before parsing (regex for numeric tokens, fix separators).
- Catch RuntimeException around the SVG parse and fall back to skipping the malformed element.
- Sanitize numbers: convert locale decimal commas to dots and remove duplicate dots before feeding the parser.
- Regenerate the SVG from a known-good editor/exporter.
Example fix
// before
float v = parserHelper.parseFloat(); // RuntimeException on '2.3.4'
// after
try {
float v = parserHelper.parseFloat();
} catch (RuntimeException e) {
Log.w(TAG, "Skipping malformed SVG number", e);
} Defensive patterns
Strategy: try-catch
Validate before calling
if (!pathData.matches("[MmZzLlHhVvCcSsQqTtAa0-9eE+\\-., \\t\\r\\n]*")) throw new IllegalArgumentException("Malformed SVG path data"); Try / catch
try { value = parserHelper.parseFloat(); } catch (RuntimeException e) { Log.w(TAG, "Unexpected char in SVG data", e); value = 0f; } Prevention
- Validate SVG path syntax before parsing
- Normalize decimal separators and stray dots
- Fuzz-test the SVG parser with malformed inputs
When it happens
Trigger: Parsing SVG path data or numeric attributes where an unexpected character appears where a number (or separator) is expected — e.g. 'parseFloat("1.2.3")', letters inside coordinates, or a malformed command sequence.
Common situations: Hand-edited or generated SVG with malformed path data (missing separators, doubled dots, stray commas/letters); SVGs exported by buggy tools; user-uploaded icons; locale-corrupted numbers with decimal commas ('1,5' in some contexts).
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- e
- Failed parsing settings file
- Failed to load rules from misc.
- Invalid attribute " + getAttributeName(index) + ": " + value
- Invalid format: componentStatus not found
AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12).
Data as JSON: /api/errors/fa127ae88d4c0f86.
Report an issue: GitHub.
Appendix: source
Thrown at app/src/main/java/io/github/muntashirakon/svg/ParserHelper.java:344
}
}
}
default:
}
if (!expPos) {
exp = -exp;
}
exp += expAdj;
if (!mantPos) {
mant = -mant;
}
return buildFloat(mant, exp);
}
private void reportUnexpectedCharacterError(char c) {
throw new RuntimeException("Unexpected char '" + c + "'.");
}
/**
* Computes a float from mantissa and exponent.
*/
public static float buildFloat(int mant, int exp) {
if (exp < -125 || mant == 0) {
return 0.0f;
}
if (exp >= 128) {
return (mant > 0)
? Float.POSITIVE_INFINITY
: Float.NEGATIVE_INFINITY;
}
if (exp == 0) {
return mant;View on GitHub (pinned to 0152f468fc)