MuntashirAkon/AppManager · error · org.xmlpull.v1.XmlPullParserException
Invalid attribute ${name}: ${e}
Error message
Invalid attribute ${name}: ${e} What it means
An attribute whose stored type is TYPE_STRING (or TYPE_STRING_INTERNED) was expected to hold hex-encoded bytes, but hexStringToBytes(valueString) failed to decode it. The parser wraps the underlying decode exception in XmlPullParserException('Invalid attribute <name>: <cause>'), naming the offending attribute.
Source
Thrown at libcore/compat/src/main/java/io/github/muntashirakon/compat/xml/BinaryXmlPullParser.java:742
default:
// Unknown data type; null is the best we can offer
return null;
}
}
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) {View on GitHub (pinned to 0152f468fc)
Solutions
- Verify the attribute value is valid hex (even length, [0-9a-fA-F]) before calling getValueBytesHex()
- Read the attribute as a string via getValueString() and decode it yourself with your own error handling
- Check which component wrote the XML and whether it intends hex encoding for this attribute
- Catch XmlPullParserException and fall back to a string read for resilient parsing
Example fix
// before
byte[] b = attr.getValueBytesHex();
// after
String v = attr.getValueString();
byte[] b = (v != null && v.length() % 2 == 0 && v.matches("[0-9a-fA-F]*"))
? hexToBytes(v) : null; Defensive patterns
Strategy: validation
Validate before calling
String v = attr.getValueString(); boolean isHex = v != null && !v.isEmpty() && v.length() % 2 == 0 && v.chars().allMatch(c -> Character.digit(c, 16) != -1 || c == '-'); if (!isHex) return null;
Try / catch
try { return attr.getValueBytesHex(); } catch (XmlPullParserException e) { return attr.getValueString().getBytes(StandardCharsets.UTF_8); } Prevention
- Validate hex strings (even length, hex alphabet) before conversion
- Confirm writer/reader agree on hex encoding for this attribute
- Fall back to string reads when bytes are optional
When it happens
Trigger: Calling Attribute.getValueBytesHex() on a string-typed attribute whose value is not valid hex (odd length, non-hex characters, null/empty where bytes were required).
Common situations: Reading binary XML written by a different producer that stored plain strings where the consumer expects hex-encoded byte arrays; schema drift between writer and reader versions.
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
- Invalid conversion from ${type}
- ${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/ed3bb3fd1a8ea7d0.
Report an issue: GitHub.