MuntashirAkon/AppManager · error · XmlPullParserException

Invalid attribute " + name + ": " + valueString

Error message

Invalid attribute " + name + ": " + valueString

What it means

Attribute.getValueBoolean() throws XmlPullParserException when a TYPE_STRING/TYPE_STRING_INTERNED attribute holds a value that is neither "true" nor "false" (case-insensitive). The message includes the attribute name and the offending string.

Source

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

                default:
                    throw new XmlPullParserException("Invalid conversion from " + type);
            }
        }

        public boolean getValueBoolean() throws XmlPullParserException {
            switch (type) {
                case TYPE_BOOLEAN_TRUE:
                    return true;
                case TYPE_BOOLEAN_FALSE:
                    return false;
                case TYPE_STRING:
                case TYPE_STRING_INTERNED:
                    if ("true".equalsIgnoreCase(valueString)) {
                        return true;
                    } else if ("false".equalsIgnoreCase(valueString)) {
                        return false;
                    } else {
                        throw new XmlPullParserException(
                                "Invalid attribute " + name + ": " + valueString);
                    }
                default:
                    throw new XmlPullParserException("Invalid conversion from " + type);
            }
        }
    }

    // NOTE: To support unbundled clients, we include an inlined copy
    // of hex conversion logic from HexDump below
    private final static char[] HEX_DIGITS =
            { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };

    private static int toByte(char c) {
        if (c >= '0' && c <= '9') return (c - '0');
        if (c >= 'A' && c <= 'F') return (c - 'A' + 10);
        if (c >= 'a' && c <= 'f') return (c - 'a' + 10);
        throw new IllegalArgumentException("Invalid hex char '" + c + "'");

View on GitHub (pinned to 0152f468fc)

Solutions

  1. Normalize the writer to emit "true"/"false" for boolean attributes.
  2. Accept alternate spellings by reading as string and mapping "1"/"yes"/"on" manually.
  3. Use getValueInt() if the producer stores booleans as 0/1 integers.
  4. Catch XmlPullParserException and apply a default.

Example fix

// before
boolean b = attr.getValueBoolean(); // "1" throws
// after
boolean b = "1".equals(attr.getValueString()) || attr.getValueBoolean();
Defensive patterns

Strategy: validation

Validate before calling

String s = attr.getValueString();
boolean boolReadable = "true".equalsIgnoreCase(s) || "false".equalsIgnoreCase(s);

Try / catch

try {
    b = attr.getValueBoolean();
} catch (XmlPullParserException e) {
    b = false; // or map alternate spellings
}

Prevention

When it happens

Trigger: Calling getValueBoolean() on a string-typed attribute with a value like "yes", "1", "on", or an empty string.

Common situations: Hand-edited or third-party binary XML where booleans were stored as "1"/"0" or "enabled"/"disabled", or locale/schema mismatches between writer and reader.

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/4f3f1ce41c133aa7. Report an issue: GitHub.