MuntashirAkon/AppManager · error · XmlPullParserException
Invalid conversion from " + type
Error message
Invalid conversion from " + type
What it means
Attribute.getValueDouble() throws XmlPullParserException from its default switch branch when the attribute's stored type is not convertible to double (e.g. TYPE_BOOLEAN_TRUE, TYPE_NULL, byte-array types). Only TYPE_DOUBLE, numeric types and TYPE_STRING/TYPE_STRING_INTERNED are accepted.
Source
Thrown at libcore/compat/src/main/java/io/github/muntashirakon/compat/xml/BinaryXmlPullParser.java:864
}
default:
throw new XmlPullParserException("Invalid conversion from " + type);
}
}
public double getValueDouble() throws XmlPullParserException {
switch (type) {
case TYPE_DOUBLE:
return valueDouble;
case TYPE_STRING:
case TYPE_STRING_INTERNED:
try {
return Double.parseDouble(valueString);
} catch (Exception e) {
throw new XmlPullParserException("Invalid attribute " + name + ": " + e);
}
default:
throw new XmlPullParserException("Invalid conversion from " + type);
}
}
public boolean getValueBoolean() throws XmlPullParserException {
switch (type) {
case TYPE_BOOLEAN_TRUE:
return true;
case TYPE_BOOLEAN_FALSE:
return false;
case TYPE_STRING:
case TYPE_STRING_INTERNED:
if ("true".equalsIgnoreCase(valueString)) {
return true;
} else if ("false".equalsIgnoreCase(valueString)) {
return false;
} else {
throw new XmlPullParserException(
"Invalid attribute " + name + ": " + valueString);View on GitHub (pinned to 0152f468fc)
Solutions
- Use the getter matching the attribute's actual type as recorded by the writer.
- Inspect Attribute.getType() first and dispatch to the correct getValueXxx method.
- Align the serializer so the attribute is written as TYPE_DOUBLE when a double is expected.
- Catch XmlPullParserException and skip/default the attribute.
Example fix
// before
double d = attr.getValueDouble(); // boolean-typed attr throws
// after
double d = (attr.getType() == XmlPullParser.TYPE_BOOLEAN_TRUE)
? (attr.getValueBoolean() ? 1.0 : 0.0)
: attr.getValueDouble(); Defensive patterns
Strategy: type-guard
Validate before calling
int t = attr.getType();
boolean ok = t == XmlPullParser.TYPE_DOUBLE || t == XmlPullParser.TYPE_INT
|| t == XmlPullParser.TYPE_LONG || t == XmlPullParser.TYPE_STRING
|| t == XmlPullParser.TYPE_STRING_INTERNED; Type guard
boolean isDoubleReadable(TypedXmlPullParser.Attribute a) {
switch (a.getType()) {
case XmlPullParser.TYPE_DOUBLE:
case XmlPullParser.TYPE_INT:
case XmlPullParser.TYPE_LONG:
case XmlPullParser.TYPE_STRING:
case XmlPullParser.TYPE_STRING_INTERNED:
return true;
default:
return false;
}
} Try / catch
try {
d = attr.getValueDouble();
} catch (XmlPullParserException e) {
d = 0.0; // or rethrow with context
} Prevention
- Match the getter to the type recorded by the writer.
- Inspect getType() when parsing documents of unknown provenance.
- Keep boolean and byte-array attributes read with their dedicated getters.
- Test parsers against documents from all supported producer versions.
When it happens
Trigger: Calling getValueDouble() on an attribute whose recorded type is TYPE_BOOLEAN_TRUE, TYPE_NULL, TYPE_BYTES_BASE64 or TYPE_BYTES_HEX.
Common situations: Mismatch between writer and reader schema (value type changed between app versions), or accidentally reading a boolean/bytes attribute as a double when parsing Android binary XML.
Understand the failure class
Background: "is not a compatible type" / "cannot merge" errors: when a value's type doesn't match what the library requires — this error's family across 65 libraries.
Related errors
- ${getPositionDescription()}
- Not applicable for token ${mCurrentToken}
- Not at START_TAG
- Invalid attribute " + name + ": " + e
- Invalid attribute " + name + ": " + valueString
AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12).
Data as JSON: /api/errors/283e9ff35b2c312e.
Report an issue: GitHub.