{"record":{"id":"0aa82de81fac7ff1","repo":"iBotPeaches/Apktool","slug":"event-text-must-be-immediately-followed-by-end-tag","errorCode":null,"errorMessage":"Event TEXT must be immediately followed by END_TAG.","messagePattern":"Event TEXT must be immediately followed by END_TAG\\.","errorType":"exception","errorClass":"XmlPullParserException","httpStatus":null,"severity":"error","filePath":"brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/BinaryXmlResourceParser.java","lineNumber":561,"sourceCode":"        }\n    }\n\n    @Override\n    public String nextText() throws XmlPullParserException, IOException {\n        if (mEventType != START_TAG) {\n            throw new XmlPullParserException(\"Parser must be on START_TAG to read next text.\", this, null);\n        }\n        int eventType = next();\n        if (eventType == END_TAG) {\n            return \"\";\n        }\n        if (eventType != TEXT) {\n            throw new XmlPullParserException(\"Parser must be on TEXT or END_TAG to read text.\", this, null);\n        }\n        String result = getText();\n        eventType = next();\n        if (eventType != END_TAG) {\n            throw new XmlPullParserException(\"Event TEXT must be immediately followed by END_TAG.\", this, null);\n        }\n        return result;\n    }\n\n    @Override\n    public int nextTag() throws XmlPullParserException, IOException {\n        int eventType = next();\n        if (eventType == TEXT && isWhitespace()) {\n            eventType = next();\n        }\n        if (eventType != START_TAG && eventType != END_TAG) {\n            throw new XmlPullParserException(\"Expected start or end tag.\", this, null);\n        }\n        return eventType;\n    }\n\n    // Utility methods\n","sourceCodeStart":543,"sourceCodeEnd":579,"githubUrl":"https://github.com/iBotPeaches/Apktool/blob/79b63384d7d7e22917e6ea8b453272da7012515b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/BinaryXmlResourceParser.java#L543-L579","documentation":"Tail check of nextText(): after reading the TEXT event, the immediately following event must be the matching END_TAG. A START_TAG (nested markup after text) or END_DOCUMENT at that position violates well-formed single-text-element semantics and throws.","triggerScenarios":"nextText() on an element like `<item>text<sub/></item>` where another tag follows the text node, or truncated AXML where the document ends right after a text node.","commonSituations":"Styled string resources compiled to AXML with inline tags; corrupt/truncated binary XML from bad extractions; packers mangling event sequences.","solutions":["Use manual event iteration (next() loop) for elements that can contain markup after text.","Re-extract the AXML if truncation is suspected; a valid AXML always closes its tags.","Validate the file with apktool's full decode — if full decode succeeds, fix the client traversal instead.","Check file size and trailing bytes (0x0101 END_DOCUMENT chunk) when corruption is suspected."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    String text = parser.nextText();\n} catch (XmlPullParserException e) {\n    if (e.getMessage().contains(\"immediately followed by END_TAG\")) {\n        // markup after text or truncated document — iterate manually / re-extract file\n    }\n}","preventionTips":["Handle styled/mixed-content strings with manual next() iteration.","Treat this on stock Android resources as a sign of file corruption and re-extract."],"tags":["apktool","xml-pull-parser","mixed-content","axml"],"backgroundTag":null,"analyzedSha":"79b63384d7d7e22917e6ea8b453272da7012515b","analyzedAt":"2026-08-14T10:43:28.812Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}