MuntashirAkon/AppManager · error · org.xmlpull.v1.XmlPullParserException
Not applicable for token ${mCurrentToken}
Error message
Not applicable for token ${mCurrentToken} What it means
XmlPullParserException from isWhitespace() when the current token is not TEXT, CDSECT, or IGNORABLE_WHITESPACE — whitespace relevance is only defined for text-like tokens. The message reports the offending token number.
Source
Thrown at libcore/compat/src/main/java/io/github/muntashirakon/compat/xml/BinaryXmlPullParser.java:533
public int getLineNumber() {
return -1;
}
@Override
public int getColumnNumber() {
return -1;
}
@Override
public boolean isWhitespace() throws XmlPullParserException {
switch (mCurrentToken) {
case IGNORABLE_WHITESPACE:
return true;
case TEXT:
case CDSECT:
return !TextUtils.isGraphic(mCurrentText);
default:
throw new XmlPullParserException("Not applicable for token " + mCurrentToken);
}
}
@Override
public String getNamespace() {
switch (mCurrentToken) {
case START_TAG:
case END_TAG:
// Namespaces are unsupported
return NO_NAMESPACE;
default:
return null;
}
}
@Override
public String getName() {
return mCurrentName;View on GitHub (pinned to 0152f468fc)
Solutions
- Only call isWhitespace() when getEventType() is TEXT, CDSECT, or IGNORABLE_WHITESPACE
- Guard with an event-type check and return false for other tokens
- In nextTag()-style loops, the TEXT branch is safe — avoid calling it elsewhere
- Log mCurrentToken from the exception message to identify the state bug
Example fix
// before
boolean ws = parser.isWhitespace();
// after
int ev = parser.getEventType();
boolean ws = (ev == XmlPullParser.TEXT || ev == XmlPullParser.CDSECT || ev == XmlPullParser.IGNORABLE_WHITESPACE)
&& parser.isWhitespace(); Defensive patterns
Strategy: validation
Validate before calling
int ev = parser.getEventType(); boolean textLike = (ev == XmlPullParser.TEXT || ev == XmlPullParser.CDSECT || ev == XmlPullParser.IGNORABLE_WHITESPACE); if (!textLike) return false;
Type guard
static boolean isTextLikeEvent(int ev) { return ev == XmlPullParser.TEXT || ev == XmlPullParser.CDSECT || ev == XmlPullParser.IGNORABLE_WHITESPACE; } Try / catch
try { ws = parser.isWhitespace(); } catch (XmlPullParserException e) { ws = false; // current token is not text-like } Prevention
- Gate isWhitespace() behind an event-type check
- Do not call it inside generic token loops
- Read the offending token number from the exception message
When it happens
Trigger: Calling isWhitespace() while positioned on START_TAG, END_TAG, START_DOCUMENT, END_DOCUMENT, or COMMENT; indirectly from nextTag() only if TEXT/CDSECT — direct calls with other current tokens throw immediately.
Common situations: Calling isWhitespace() without checking getEventType() first; custom token loops that call it unconditionally for every token; porting code that assumed KXmlParser's more permissive behavior.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- Not at START_TAG
- ${getPositionDescription()}
- Namespaces are not supported
- Invalid attribute ${name}: ${e}
- Invalid conversion from ${type}
AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12).
Data as JSON: /api/errors/1fc8f190f0b352c5.
Report an issue: GitHub.