MuntashirAkon/AppManager · error · java.io.IOException
Unexpected data type
Error message
Unexpected data type ${type} What it means
While consuming a token (an attribute value in this path), the parser reads a type byte and switches over the known TYPE_* constants. A type outside the supported set (beyond STRING, INT, etc., up to DOUBLE) indicates a malformed or newer-protocol stream, so an IOException "Unexpected data type <type>" is thrown.
Solutions
- Regenerate or re-export the binary XML file with a matching library version.
- Check that the InputStream starts exactly at the document start (magic bytes) so type bytes align.
- Update the library to a version that supports the data types present in the file.
- Treat the file as corrupt and fall back to a backup copy.
Example fix
// before parser.setInput(offsetStreamSkippingHeader, null); // misaligned type bytes // after parser.setInput(freshStreamAtStart, null); // read from position 0
Defensive patterns
Strategy: try-catch
Validate before calling
// Verify format up front so type bytes stay aligned:
byte[] magic = new byte[4];
if (is.read(magic) != 4 || !Arrays.equals(magic, PROTOCOL_MAGIC_VERSION_0)) {
throw new IOException("Not a v0 binary XML stream");
} Try / catch
try {
parser.setInput(is, null);
while (parser.next() != XmlPullParser.END_DOCUMENT) { /* ... */ }
} catch (IOException e) {
// treat document as corrupt; regenerate or fall back
} Prevention
- Read the stream from the very beginning so type bytes align with the protocol.
- Match reader and writer library versions.
- Never continue parsing after a mid-token failure; restart from a fresh stream.
When it happens
Trigger: consumeToken() encounters an attribute value type byte not defined by protocol version 0 — caused by corrupted data, a stream desynchronized from the token boundaries, or a file written by a newer writer with additional types.
Common situations: Hand-edited or corrupted binary XML files; reading from the wrong offset so type bytes land on data bytes; forward-compatibility issues with files from newer library versions; bit rot in stored files.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12).
Data as JSON: /api/errors/d48b129529bfffdb.
Report an issue: GitHub.
Appendix: source
Thrown at libcore/compat/src/main/java/io/github/muntashirakon/compat/xml/BinaryXmlPullParser.java:246
mIn.readFully(res);
attr.valueBytes = res;
break;
case TYPE_INT:
case TYPE_INT_HEX:
attr.valueInt = mIn.readInt();
break;
case TYPE_LONG:
case TYPE_LONG_HEX:
attr.valueLong = mIn.readLong();
break;
case TYPE_FLOAT:
attr.valueFloat = mIn.readFloat();
break;
case TYPE_DOUBLE:
attr.valueDouble = mIn.readDouble();
break;
default:
throw new IOException("Unexpected data type " + type);
}
break;
}
case XmlPullParser.START_DOCUMENT: {
mCurrentName = null;
mCurrentText = null;
if (mAttributeCount > 0) resetAttributes();
break;
}
case XmlPullParser.END_DOCUMENT: {
mCurrentName = null;
mCurrentText = null;
if (mAttributeCount > 0) resetAttributes();
break;
}
case XmlPullParser.START_TAG: {
mCurrentName = mIn.readInternedUTF();
mCurrentText = null;View on GitHub (pinned to 0152f468fc)