MuntashirAkon/AppManager · error · XmlPullParserException
Invalid attribute " + getAttributeName(index) + ": " + value
Error message
Invalid attribute " + getAttributeName(index) + ": " + value
What it means
XmlUtils.getAttributeBoolean parses an XML attribute value as a boolean. If the attribute's text is neither "true" nor "false" (case-insensitive), it throws XmlPullParserException naming the attribute and its raw value. This library mirrors Android's XmlUtils and treats non-boolean attribute values as a hard parse failure rather than returning a default.
Source
Thrown at libcore/compat/src/main/java/io/github/muntashirakon/compat/xml/XmlUtils.java:202
throws XmlPullParserException {
try {
return Double.parseDouble(getAttributeValue(index));
} catch (Exception e) {
throw new XmlPullParserException(
"Invalid attribute " + getAttributeName(index) + ": " + e);
}
}
@Override
public boolean getAttributeBoolean(int index)
throws XmlPullParserException {
final String value = getAttributeValue(index);
if ("true".equalsIgnoreCase(value)) {
return true;
} else if ("false".equalsIgnoreCase(value)) {
return false;
} else {
throw new XmlPullParserException(
"Invalid attribute " + getAttributeName(index) + ": " + value);
}
}
}
/**
* Return a specialization of the given {@link XmlPullParser} which has
* explicit methods to support consistent and efficient conversion of
* primitive data types.
*/
public static @NonNull TypedXmlPullParser makeTyped(@NonNull XmlPullParser xml) {
if (xml instanceof TypedXmlPullParser) {
return (TypedXmlPullParser) xml;
} else {
return new ForcedTypedXmlPullParser(xml);
}
}
View on GitHub (pinned to 0152f468fc)
Solutions
- Fix the XML so the attribute value is exactly "true" or "false" (case-insensitive)
- Use getAttributeValue(index) and parse manually with Boolean.parseBoolean or your own mapping when non-standard values must be accepted
- Check for typos/whitespace in the attribute value before calling
Example fix
// before: <package debug="1"> int flags = XmlUtils.getAttributeBoolean(parser, "debug") // throws // after boolean debug = "1".equals(parser.getAttributeValue(null, "debug")); // or fix XML to <package debug="true">
Defensive patterns
Strategy: validation
Validate before calling
String v = parser.getAttributeValue(null, "debug");
if (v != null && !"true".equalsIgnoreCase(v) && !"false".equalsIgnoreCase(v)) {
throw new IllegalArgumentException("Attribute 'debug' is not a boolean: " + v);
} Type guard
boolean isBooleanAttr(String v) {
return "true".equalsIgnoreCase(v) || "false".equalsIgnoreCase(v);
} Try / catch
try {
flag = XmlUtils.getAttributeBoolean(parser, index);
} catch (XmlPullParserException e) {
Log.w(TAG, "Non-boolean attribute, defaulting", e);
flag = false; // or fail-fast depending on strictness
} Prevention
- Author XML with only true/false for boolean attributes
- Prefer reading raw attribute values and parsing yourself when accepting 1/0 or yes/no
- Validate XML against a schema before parsing
When it happens
Trigger: Calling getAttributeBoolean(index) (or the name-based overload that resolves to it) on an attribute whose string value is anything other than "true"/"false" — e.g. "1", "0", "yes", "", or a typo like "ture".
Common situations: Hand-written or third-party XML using 1/0 or yes/no for booleans; attributes edited manually with typos; XML produced by another tool with different boolean conventions.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Invalid tag inside <set>: ${tagName}
- Invalid tag: ${tagName}
- Invalid attribute " + name + ": " + valueString
- e
- "manifest" has duplicate "application" tags.
AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12).
Data as JSON: /api/errors/c6f4b9bb8a6aeee4.
Report an issue: GitHub.