MuntashirAkon/AppManager · error · XmlPullParserException

Invalid attribute " + name + ": " + e

Error message

Invalid attribute " + name + ": " + e

What it means

Attribute.getValueDouble() throws XmlPullParserException when the attribute's string representation cannot be parsed as a double (stored type TYPE_STRING/TYPE_STRING_INTERNED). The message embeds the attribute name and the underlying NumberFormatException.

Source

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

                        return Float.parseFloat(valueString);
                    } catch (Exception e) {
                        throw new XmlPullParserException("Invalid attribute " + name + ": " + e);
                    }
                default:
                    throw new XmlPullParserException("Invalid conversion from " + type);
            }
        }

        public double getValueDouble() throws XmlPullParserException {
            switch (type) {
                case TYPE_DOUBLE:
                    return valueDouble;
                case TYPE_STRING:
                case TYPE_STRING_INTERNED:
                    try {
                        return Double.parseDouble(valueString);
                    } catch (Exception e) {
                        throw new XmlPullParserException("Invalid attribute " + name + ": " + e);
                    }
                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;

View on GitHub (pinned to 0152f468fc)

Solutions

  1. Fix the producer to write valid double literals (Locale-invariant formatting, e.g. Double.toString).
  2. Pre-validate the string with Double.parseDouble in a try-catch before parsing, or use a fallback default.
  3. Use the getter matching the attribute's actual type (TYPE_DOUBLE attributes parse directly and won't take this branch).
  4. Catch XmlPullParserException and treat the attribute as missing/invalid.

Example fix

// before
double d = attr.getValueDouble(); // "1,5" throws
// after
double d;
try { d = attr.getValueDouble(); }
catch (XmlPullParserException e) { d = 0.0; /* or log & recover */ }
Defensive patterns

Strategy: validation

Validate before calling

String s = attr.getValueString();
boolean parseable = s != null;
if (parseable) {
    try { Double.parseDouble(s); } catch (NumberFormatException e) { parseable = false; }
}

Try / catch

try {
    d = attr.getValueDouble();
} catch (XmlPullParserException e) {
    d = DEFAULT_DOUBLE; // log e.getMessage() for diagnostics
}

Prevention

When it happens

Trigger: Calling getValueDouble() on a string-typed attribute whose value is not a valid double literal, e.g. "abc", "1,5", or an empty string.

Common situations: Binary XML written by another tool/locale where numbers were serialized with commas or units, or a schema change that stored a non-numeric string where a double was expected.

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


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