{"record":{"id":"283e9ff35b2c312e","repo":"MuntashirAkon/AppManager","slug":"invalid-conversion-from-type-binaryxmlpullparser","errorCode":null,"errorMessage":"Invalid conversion from \" + type","messagePattern":"Invalid conversion from \" \\+ type","errorType":"exception","errorClass":"XmlPullParserException","httpStatus":null,"severity":"error","filePath":"libcore/compat/src/main/java/io/github/muntashirakon/compat/xml/BinaryXmlPullParser.java","lineNumber":864,"sourceCode":"                    }\n                default:\n                    throw new XmlPullParserException(\"Invalid conversion from \" + type);\n            }\n        }\n\n        public double getValueDouble() throws XmlPullParserException {\n            switch (type) {\n                case TYPE_DOUBLE:\n                    return valueDouble;\n                case TYPE_STRING:\n                case TYPE_STRING_INTERNED:\n                    try {\n                        return Double.parseDouble(valueString);\n                    } catch (Exception e) {\n                        throw new XmlPullParserException(\"Invalid attribute \" + name + \": \" + e);\n                    }\n                default:\n                    throw new XmlPullParserException(\"Invalid conversion from \" + type);\n            }\n        }\n\n        public boolean getValueBoolean() throws XmlPullParserException {\n            switch (type) {\n                case TYPE_BOOLEAN_TRUE:\n                    return true;\n                case TYPE_BOOLEAN_FALSE:\n                    return false;\n                case TYPE_STRING:\n                case TYPE_STRING_INTERNED:\n                    if (\"true\".equalsIgnoreCase(valueString)) {\n                        return true;\n                    } else if (\"false\".equalsIgnoreCase(valueString)) {\n                        return false;\n                    } else {\n                        throw new XmlPullParserException(\n                                \"Invalid attribute \" + name + \": \" + valueString);","sourceCodeStart":846,"sourceCodeEnd":882,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/libcore/compat/src/main/java/io/github/muntashirakon/compat/xml/BinaryXmlPullParser.java#L846-L882","documentation":"Attribute.getValueDouble() throws XmlPullParserException from its default switch branch when the attribute's stored type is not convertible to double (e.g. TYPE_BOOLEAN_TRUE, TYPE_NULL, byte-array types). Only TYPE_DOUBLE, numeric types and TYPE_STRING/TYPE_STRING_INTERNED are accepted.","triggerScenarios":"Calling getValueDouble() on an attribute whose recorded type is TYPE_BOOLEAN_TRUE, TYPE_NULL, TYPE_BYTES_BASE64 or TYPE_BYTES_HEX.","commonSituations":"Mismatch between writer and reader schema (value type changed between app versions), or accidentally reading a boolean/bytes attribute as a double when parsing Android binary XML.","solutions":["Use the getter matching the attribute's actual type as recorded by the writer.","Inspect Attribute.getType() first and dispatch to the correct getValueXxx method.","Align the serializer so the attribute is written as TYPE_DOUBLE when a double is expected.","Catch XmlPullParserException and skip/default the attribute."],"exampleFix":"// before\ndouble d = attr.getValueDouble(); // boolean-typed attr throws\n// after\ndouble d = (attr.getType() == XmlPullParser.TYPE_BOOLEAN_TRUE)\n        ? (attr.getValueBoolean() ? 1.0 : 0.0)\n        : attr.getValueDouble();","handlingStrategy":"type-guard","validationCode":"int t = attr.getType();\nboolean ok = t == XmlPullParser.TYPE_DOUBLE || t == XmlPullParser.TYPE_INT\n        || t == XmlPullParser.TYPE_LONG || t == XmlPullParser.TYPE_STRING\n        || t == XmlPullParser.TYPE_STRING_INTERNED;","typeGuard":"boolean isDoubleReadable(TypedXmlPullParser.Attribute a) {\n    switch (a.getType()) {\n        case XmlPullParser.TYPE_DOUBLE:\n        case XmlPullParser.TYPE_INT:\n        case XmlPullParser.TYPE_LONG:\n        case XmlPullParser.TYPE_STRING:\n        case XmlPullParser.TYPE_STRING_INTERNED:\n            return true;\n        default:\n            return false;\n    }\n}","tryCatchPattern":"try {\n    d = attr.getValueDouble();\n} catch (XmlPullParserException e) {\n    d = 0.0; // or rethrow with context\n}","preventionTips":["Match the getter to the type recorded by the writer.","Inspect getType() when parsing documents of unknown provenance.","Keep boolean and byte-array attributes read with their dedicated getters.","Test parsers against documents from all supported producer versions."],"tags":["xml","parser","type-conversion"],"backgroundTag":"incompatible-source-type","analyzedSha":"0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5","analyzedAt":"2026-09-12T14:03:37.243Z","contentChangedAt":"2026-09-12T14:03:37.243Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}