{"record":{"id":"e1b23d0f9557782f","repo":"iBotPeaches/Apktool","slug":"input-file-is-empty-e1b23d","errorCode":null,"errorMessage":"Input file is empty.","messagePattern":"Input file is empty\\.","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"critical","filePath":"brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/BinaryXmlResourceParser.java","lineNumber":116,"sourceCode":"    }\n\n    @Override\n    public void setInput(Reader in) throws XmlPullParserException {\n        throw new XmlPullParserException(NOT_SUPPORTED);\n    }\n\n    @Override\n    public void setInput(InputStream inputStream, String inputEncoding) throws XmlPullParserException {\n        if (inputEncoding != null) {\n            throw new XmlPullParserException(NOT_SUPPORTED);\n        }\n\n        reset();\n        mIn = new BinaryDataInputStream(new BufferedInputStream(inputStream));\n        mParser = new ResChunkPullParser(mIn);\n        try {\n            if (!nextChunk()) {\n                throw new IOException(\"Input file is empty.\");\n            }\n            if (mParser.chunkType() != ResChunkHeader.RES_XML_TYPE) {\n                throw new IOException(\"Unexpected chunk: \" + mParser.chunkName() + \" (expected: RES_XML_TYPE)\");\n            }\n        } catch (IOException ex) {\n            mIn = null;\n            mParser = null;\n            throw new XmlPullParserException(\"Could not initialize parser.\", this, ex);\n        }\n\n        mParser = new ResChunkPullParser(mIn, mParser.dataSize());\n    }\n\n    @Override\n    public String getInputEncoding() {\n        return null;\n    }\n","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/iBotPeaches/Apktool/blob/79b63384d7d7e22917e6ea8b453272da7012515b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/BinaryXmlResourceParser.java#L98-L134","documentation":"BinaryXmlResourceParser.setInput throws (as IOException, wrapped at [32]) when the input stream for a binary XML file (AXML) yields no chunk at all — the file is empty. This is the AXML counterpart of the arsc 'Input file is empty.' error.","triggerScenarios":"Calling setInput() with a zero-length stream: an empty layout XML, a truncated AndroidManifest.xml pulled from a broken extraction, or a wrongly-resolved path that opened /dev/null-like empty file.","commonSituations":"ADB pulls interrupted midway leaving 0-byte XML files; repack tools emitting empty AXML entries; automated pipelines iterating over a directory where some files failed to extract.","solutions":["Check the file size of the AXML before parsing; a valid one is at least a few dozen bytes.","Re-pull or re-extract the file and verify non-zero size and a leading 0x0003 chunk type.","If the entry is empty inside the APK itself (`unzip -l`), the APK is corrupt — re-obtain it.","Guard batch jobs to skip/log empty files instead of feeding them to the parser."],"exampleFix":"// before\nparser.setInput(new FileInputStream(axmlFile), null);\n\n// after\nif (axmlFile.length() == 0) {\n    throw new IllegalArgumentException(\"AXML file is empty: \" + axmlFile);\n}\nparser.setInput(new FileInputStream(axmlFile), null);","handlingStrategy":"validation","validationCode":"if (axmlFile.length() == 0) {\n    throw new IllegalArgumentException(\"AXML empty: \" + axmlFile);\n}\ntry (RandomAccessFile raf = new RandomAccessFile(axmlFile, \"r\")) {\n    int b0 = raf.read(), b1 = raf.read();\n    if (b0 != 0x03 || b1 != 0x00) throw new IllegalArgumentException(\"Not binary XML\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    parser.setInput(new FileInputStream(f), null);\n} catch (XmlPullParserException e) {\n    if (e.getCause() != null && e.getCause().getMessage().equals(\"Input file is empty.\")) {\n        // re-extract the file\n    }\n}","preventionTips":["Size- and magic-check AXML files before parsing.","Re-pull files when adb pull is interrupted.","Log and skip empty entries in batch extraction loops."],"tags":["apktool","axml","parsing","corrupt-file","xml"],"backgroundTag":null,"analyzedSha":"79b63384d7d7e22917e6ea8b453272da7012515b","analyzedAt":"2026-08-14T10:43:28.812Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}