{"record":{"id":"634513b83def356c","repo":"Tencent/matrix","slug":"parse-xml-error-e-getmessage","errorCode":null,"errorMessage":"Parse xml error,<e.getMessage()>","messagePattern":"Parse xml error,<e\\.getMessage\\(\\)>","errorType":"exception","errorClass":"AndrolibException","httpStatus":null,"severity":"error","filePath":"matrix/matrix-android/matrix-apk-canary/src/main/java/com/tencent/matrix/apk/model/task/util/XmlPullResourceRefDecoder.java","lineNumber":71,"sourceCode":"            while (token != XmlPullParser.END_DOCUMENT) {\n                switch (token) {\n                    case XmlPullParser.START_TAG:\n                        handleElement();\n                        break;\n                    case XmlPullParser.TEXT:\n                        handleContent();\n                        break;\n                    default:\n                        break;\n                }\n                token = mParser.next();\n            }\n//            Log.i(TAG, \"find resource references: %s\", resourceRefSet);\n            inputStream.close();\n        } catch (XmlPullParserException var7) {\n            throw new AndrolibException(\"Could not decode XML,\" + var7.getMessage(), var7);\n        } catch (IOException e) {\n            throw new AndrolibException(\"Parse xml error,\" + e.getMessage(), e);\n        }\n    }\n\n    private void handleElement() {\n        String tagName = mParser.getName();\n        int pointIndex = tagName.lastIndexOf('.');\n        if (pointIndex >= 0) {\n            tagName = tagName.substring(pointIndex + 1);\n        }\n        if (!Util.isNullOrNil(tagName)) {\n            for (int i = 0; i < mParser.getAttributeCount(); i++) {\n                String value = mParser.getAttributeValue(i);\n                //Log.d(TAG, \"attribute %s, %s\", name, value);\n                if (!Util.isNullOrNil(value)) {\n                    if (value.startsWith(\"@\")) {\n                        int index = value.indexOf('/');\n                        if (index > 1) {\n                            String type = value.substring(1, index);","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/Tencent/matrix/blob/3b8293bd65d47eeea7caf1f32a3a5d4d5eab60e7/matrix/matrix-android/matrix-apk-canary/src/main/java/com/tencent/matrix/apk/model/task/util/XmlPullResourceRefDecoder.java#L53-L89","documentation":"XmlPullResourceRefDecoder.decode() wraps IOExceptions encountered while reading the XML stream in AndrolibException(\"Parse xml error,...\"). This is a read failure of the XML input stream (unavailable, closed, truncated, or IO interruption), distinct from the structural XmlPullParserException path.","triggerScenarios":"The InputStream backing decode() (file stream into an APK entry or res/raw resource) throws IOException: missing zip entry, partially extracted file, or closed/failed stream.","commonSituations":"Incomplete APK extraction caused by low disk space; analyzing an APK whose entries were removed/packed so streams can't be opened; filesystem errors on the unzip output directory.","solutions":["Check the cause IOException message to identify the unread stream/file.","Re-extract the APK to a clean output directory and ensure sufficient disk space.","Confirm the APK contains the expected resource entries (inspect with apktool or unzip -l)."],"exampleFix":"// before\n// re-running check on a partially extracted directory\n// after\nFileUtils.deleteDirectory(unzipDir); // clean re-unzip before re-running\ntask.call();","handlingStrategy":"try-catch","validationCode":"ZipEntry entry = zipFile.getEntry(entryName);\nif (entry == null) {\n    throw new IllegalStateException(\"Zip entry missing: \" + entryName);\n}\ntry (InputStream in = zipFile.getInputStream(entry)) {\n    if (in.read() == -1) throw new IllegalStateException(\"Empty stream: \" + entryName);\n}","typeGuard":null,"tryCatchPattern":"try {\n    decoder.decode(inputStream);\n} catch (AndrolibException e) {\n    if (e.getMessage().startsWith(\"Parse xml error\")) {\n        logger.error(\"XML stream read failed: \" + e.getMessage(), e.getCause()); // check disk space / entry integrity\n    } else throw e;\n}","preventionTips":["Ensure enough disk space before extracting large APKs.","Open the InputStream and pass it before any other consumer can close it.","Verify APK entry integrity with unzip -t when read failures recur."],"tags":["apk-canary","io-error","xml-parsing"],"backgroundTag":"file-read-failed","analyzedSha":"3b8293bd65d47eeea7caf1f32a3a5d4d5eab60e7","analyzedAt":"2026-09-08T08:01:39.722Z","contentChangedAt":"2026-09-08T08:01:39.722Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}