{"record":{"id":"4328d06c8b94567f","repo":"skylot/jadx","slug":"binaryxmlparser-init-error","errorCode":null,"errorMessage":"BinaryXMLParser init error","messagePattern":"BinaryXMLParser init error","errorType":"exception","errorClass":"JadxRuntimeException","httpStatus":null,"severity":"error","filePath":"jadx-core/src/main/java/jadx/core/xmlgen/BinaryXMLParser.java","lineNumber":60,"sourceCode":"\tprivate boolean firstElement;\n\tprivate ValuesParser valuesParser;\n\tprivate boolean isLastEnd = true;\n\tprivate boolean isOneLine = true;\n\tprivate int namespaceDepth = 0;\n\tprivate @Nullable int[] resourceIds;\n\tprivate String appPackageName;\n\n\tprivate Map<String, ClassNode> classNameCache;\n\n\tpublic BinaryXMLParser(RootNode rootNode) {\n\t\tthis.rootNode = rootNode;\n\t\tthis.manifestAttributes = rootNode.initManifestAttributes();\n\t\tthis.attrNewLine = !rootNode.getArgs().isSkipXmlPrettyPrint();\n\t\ttry {\n\t\t\tConstStorage constStorage = rootNode.getConstValues();\n\t\t\tresNames = constStorage.getResourcesNames();\n\t\t} catch (Exception e) {\n\t\t\tthrow new JadxRuntimeException(\"BinaryXMLParser init error\", e);\n\t\t}\n\t}\n\n\tpublic synchronized ICodeInfo parse(InputStream inputStream) throws IOException {\n\t\tresourceIds = null;\n\t\tis = new ParserStream(inputStream);\n\t\tif (!isBinaryXml()) {\n\t\t\treturn ResourcesLoader.loadToCodeWriter(is);\n\t\t}\n\t\tnsMapGenerated = new HashSet<>();\n\t\tnsMap = new HashMap<>();\n\t\tdefinedNamespaces = new HashSet<>();\n\t\twriter = rootNode.makeCodeWriter();\n\t\twriter.add(\"<?xml version=\\\"1.0\\\" encoding=\\\"utf-8\\\"?>\");\n\t\tfirstElement = true;\n\t\tdecode();\n\t\tnsMap = null;\n\t\tdefinedNamespaces = null;","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/skylot/jadx/blob/e738a26571d02919f01df40de93bc9a44dee4e18/jadx-core/src/main/java/jadx/core/xmlgen/BinaryXMLParser.java#L42-L78","documentation":"Thrown in the BinaryXMLParser constructor when rootNode.getConstValues() or constStorage.getResourcesNames() throws. The constructor initializes the resource-name map needed for binary XML (AndroidManifest.xml) parsing. A failure here indicates an internal jadx state problem — the RootNode was not fully initialized, or the ConstStorage encountered an error collecting constant values from the DEX files.","triggerScenarios":"Constructing a BinaryXMLParser with a RootNode whose ConstStorage has not been populated or threw during population. Calling getConstValues() before decompilation/constant-collection has run. An internal NPE if rootNode fields are null due to partial initialization.","commonSituations":"Programmatic use of jadx APIs that constructs a BinaryXMLParser before the full decompilation pipeline has initialized the RootNode. A corrupted or obfuscated DEX input that causes ConstStorage to throw. Memory pressure causing incomplete initialization.","solutions":["Ensure the RootNode is fully initialized (all DEX files loaded, const values collected) before constructing BinaryXMLParser.","Follow the standard jadx decompilation entry point rather than constructing BinaryXMLParser directly.","Inspect the wrapped cause to identify whether the failure is in getConstValues() or getResourcesNames().","If the input APK/DEX is corrupted, validate it with standard tools (apksigner, unzip) first."],"exampleFix":"// before — constructing parser too early\nBinaryXMLParser parser = new BinaryXMLParser(rootNode);\n\n// after — ensure const values are populated first\nrootNode.getConstValues(); // force initialization\nBinaryXMLParser parser = new BinaryXMLParser(rootNode);","handlingStrategy":"validation","validationCode":"public static boolean isRootNodeReady(RootNode rootNode) {\n    try {\n        rootNode.getConstValues().getResourcesNames();\n        return true;\n    } catch (Exception e) {\n        return false;\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    BinaryXMLParser parser = new BinaryXMLParser(rootNode);\n} catch (JadxRuntimeException e) {\n    LOG.error(\"BinaryXMLParser init failed: {}\", e.getCause().getMessage());\n    // skip XML parsing for this resource\n}","preventionTips":["Fully initialize the RootNode (load DEX, collect constants) before constructing BinaryXMLParser.","Use the standard jadx decompilation pipeline entry points rather than constructing internal classes directly.","Inspect the cause to determine if the failure is in ConstStorage or resource name collection."],"tags":["xml-parsing","binary-xml","init","internal-state","jadx"],"backgroundTag":null,"analyzedSha":"e738a26571d02919f01df40de93bc9a44dee4e18","analyzedAt":"2026-08-14T00:10:24.238Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}