MuntashirAkon/AppManager · error · org.xmlpull.v1.XmlPullParserException

${getPositionDescription()}

Error message

${getPositionDescription()}

What it means

XmlPullParserException thrown by require() when the parser's current token type or element name does not match the expected type/namespace/name passed in. This binary XML parser rejects namespaces entirely (illegalNamespace() is thrown first if a non-empty namespace is given), so require() only checks token type and local name against mCurrentToken and mCurrentName.

Source

Thrown at libcore/compat/src/main/java/io/github/muntashirakon/compat/xml/BinaryXmlPullParser.java:350

            case "lt": return "<";
            case "gt": return ">";
            case "amp": return "&";
            case "apos": return "'";
            case "quot": return "\"";
        }
        if (entity.length() > 1 && entity.charAt(0) == '#') {
            final char c = (char) Integer.parseInt(entity.substring(1));
            return new String(new char[] { c });
        }
        throw new XmlPullParserException("Unknown entity " + entity);
    }

    @Override
    public void require(int type, String namespace, String name)
            throws XmlPullParserException, IOException {
        if (namespace != null && !namespace.isEmpty()) throw illegalNamespace();
        if (mCurrentToken != type || !Objects.equals(mCurrentName, name)) {
            throw new XmlPullParserException(getPositionDescription());
        }
    }

    @Override
    public String nextText() throws XmlPullParserException, IOException {
        if (getEventType() != START_TAG) {
            throw new XmlPullParserException(getPositionDescription());
        }
        int eventType = next();
        if (eventType == TEXT) {
            String result = getText();
            eventType = next();
            if (eventType != END_TAG) {
                throw new XmlPullParserException(getPositionDescription());
            }
            return result;
        } else if (eventType == END_TAG) {
            return "";

View on GitHub (pinned to 0152f468fc)

Solutions

  1. Pass null or "" as the namespace argument since namespaces are unsupported in this parser
  2. Verify the current event with getEventType() before calling require
  3. Dump the current token and name via getPositionDescription()/getName() to see the actual mismatch
  4. Regenerate or update the expected element name/path to match the actual binary XML

Example fix

// before
parser.require(XmlPullParser.START_TAG, "http://schemas.android.com/apk/res/android", "manifest");
// after
parser.require(XmlPullParser.START_TAG, null, "manifest");
Defensive patterns

Strategy: validation

Validate before calling

if (parser.getEventType() == XmlPullParser.START_TAG && "expectedName".equals(parser.getName())) {
    parser.require(XmlPullParser.START_TAG, null, "expectedName");
}

Try / catch

try { parser.require(XmlPullParser.START_TAG, null, name); } catch (XmlPullParserException e) { throw new IOException("Unexpected element at " + e.getMessage(), e); }

Prevention

When it happens

Trigger: Calling require(type, namespace, name) while the parser is positioned on a different token type (e.g. START_TAG expected but parser is on TEXT), or on an element with a different name; or passing a non-null, non-empty namespace which triggers rejection before the type check.

Common situations: Parsing Android binary XML (compiled layouts, AXML) that has a different structure than expected; porting code written against the platform XmlPullParser and passing namespaces; deserializing a resource that changed between app versions.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12). Data as JSON: /api/errors/4bc077635f435b67. Report an issue: GitHub.