MuntashirAkon/AppManager · error · org.xmlpull.v1.XmlPullParserException
Invalid conversion from ${type}
Error message
Invalid conversion from ${type} What it means
Attribute.getValueBytesHex()/related converters throw XmlPullParserException('Invalid conversion from <type>') when the attribute's binary XML type is neither TYPE_NULL, a byte-array type, nor a string type — i.e. the stored type (int, float, boolean, dimension, etc.) cannot be converted to the requested byte[] representation.
Source
Thrown at libcore/compat/src/main/java/io/github/muntashirakon/compat/xml/BinaryXmlPullParser.java:745
}
}
public @Nullable byte[] getValueBytesHex() throws XmlPullParserException {
switch (type) {
case TYPE_NULL:
return null;
case TYPE_BYTES_HEX:
case TYPE_BYTES_BASE64:
return valueBytes;
case TYPE_STRING:
case TYPE_STRING_INTERNED:
try {
return hexStringToBytes(valueString);
} catch (Exception e) {
throw new XmlPullParserException("Invalid attribute " + name + ": " + e);
}
default:
throw new XmlPullParserException("Invalid conversion from " + type);
}
}
public @Nullable byte[] getValueBytesBase64() throws XmlPullParserException {
switch (type) {
case TYPE_NULL:
return null;
case TYPE_BYTES_HEX:
case TYPE_BYTES_BASE64:
return valueBytes;
case TYPE_STRING:
case TYPE_STRING_INTERNED:
try {
return Base64.decode(valueString, Base64.NO_WRAP);
} catch (Exception e) {
throw new XmlPullParserException("Invalid attribute " + name + ": " + e);
}
default:View on GitHub (pinned to 0152f468fc)
Solutions
- Check the attribute's type (or your schema) before requesting byte conversion
- Use the type-appropriate getter (getInt, getFloat, getValueString, ...) instead of forcing a byte[] read
- Handle TYPE_NULL explicitly and skip conversion for non-convertible types
- Catch XmlPullParserException around conversions and return a typed default
Example fix
// before
byte[] b = attr.getValueBytesHex(); // fails when type is TYPE_INT
// after
byte[] b = attr.getType() == TYPE_BYTES_HEX || attr.getType() == TYPE_BYTES_BASE64
? attr.getValueBytes() : null; Defensive patterns
Strategy: type-guard
Validate before calling
int t = attr.getType(); if (t != TYPE_NULL && t != TYPE_BYTES_HEX && t != TYPE_BYTES_BASE64 && t != TYPE_STRING && t != TYPE_STRING_INTERNED) return null;
Type guard
boolean isByteCompatible(Attribute a) { int t = a.getType(); return t == TYPE_NULL || t == TYPE_BYTES_HEX || t == TYPE_BYTES_BASE64 || t == TYPE_STRING || t == TYPE_STRING_INTERNED; } Try / catch
try { return attr.getValueBytesHex(); } catch (XmlPullParserException e) { log.warn("non-byte attribute"); return null; } Prevention
- Check attribute type before requesting byte conversion
- Keep writer and reader schemas in sync
- Use type-specific getters for numeric/boolean attributes
When it happens
Trigger: Calling getValueBytesHex() (or getValueBytesBase64()) on an attribute whose underlying binary XML type is a numeric/boolean/other non-byte type.
Common situations: Generic attribute-reading code that assumes any attribute can yield bytes; schema changes where an attribute switched from byte[] to int or string between versions.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- Invalid attribute ${name}: ${e}
- ${getPositionDescription()}
- Not applicable for token ${mCurrentToken}
- Not at START_TAG
- Namespaces are not supported
AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12).
Data as JSON: /api/errors/e59c1f1737ff2329.
Report an issue: GitHub.