{"record":{"id":"904e53d6346f8639","repo":"iBotPeaches/Apktool","slug":"input-file-is-empty","errorCode":null,"errorMessage":"Input file is empty.","messagePattern":"Input file is empty\\.","errorType":"exception","errorClass":"AndrolibException","httpStatus":null,"severity":"critical","filePath":"brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/BinaryResourceParser.java","lineNumber":129,"sourceCode":"        return mHasCompactEntries;\n    }\n\n    public void enableCollectFlagsOffsets() {\n        mEntrySpecFlagsOffsets = new ArrayList<>();\n    }\n\n    public Collection<Pair<Long, Integer>> getEntrySpecFlagsOffsets() {\n        return mEntrySpecFlagsOffsets;\n    }\n\n    public void parse(InputStream in) throws AndrolibException {\n        reset();\n        mIn = new BinaryDataInputStream(new BufferedInputStream(in));\n\n        ResChunkPullParser parser = new ResChunkPullParser(mIn);\n        try {\n            if (!nextChunk(parser)) {\n                throw new AndrolibException(\"Input file is empty.\");\n            }\n            if (parser.chunkType() != ResChunkHeader.RES_TABLE_TYPE) {\n                throw new AndrolibException(\"Unexpected chunk: \" + parser.chunkName() + \" (expected: RES_TABLE_TYPE)\");\n            }\n\n            parseTable(parser);\n\n            Log.d(TAG, \"End of chunks at 0x%08x\", mIn.position());\n\n            // We can't use remaining() here, the length of the main stream is unknown.\n            if (mIn.available() > 0) {\n                Log.d(TAG, \"Ignoring trailing data at 0x%08x.\", mIn.position());\n            }\n        } catch (IOException ex) {\n            throw new AndrolibException(\"Could not decode arsc file.\", ex);\n        }\n    }\n","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/iBotPeaches/Apktool/blob/79b63384d7d7e22917e6ea8b453272da7012515b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/BinaryResourceParser.java#L111-L147","documentation":"BinaryResourceParser.parse throws this when the very first attempt to read a chunk from resources.arsc hits end-of-stream, i.e. the supplied InputStream contains no resource-table data at all. It means the arsc input is zero-length or truncated to nothing before any chunk header.","triggerScenarios":"Calling `parse(InputStream)` with an empty or truncated resources.arsc — e.g. an APK rebuilt with a broken packaging step, a 0-byte arsc extracted by a faulty unzip, or passing the wrong stream to the parser.","commonSituations":"Repackaging pipelines that produce empty resources.arsc; CI jobs where the artifact download was interrupted; manual extraction where the arsc got clobbered; feeding a compressed-but-not-inflated stream.","solutions":["Verify the APK integrity: `unzip -l app.apk | grep resources.arsc` — the entry must have a non-zero size.","Re-extract or re-download the APK and confirm `resources.arsc` is > 0 bytes before decoding.","If you built the arsc yourself (aapt2/custom tool), check that step actually wrote table data.","Open the file in a hex viewer: it must start with chunk type 0x0002 (RES_TABLE_TYPE) — an empty file confirms truncation."],"exampleFix":"// before\nparser.parse(apkDir.toPath().resolve(\"resources.arsc\").toFile().toInputStream());\n\n// after\nFile arsc = apkDir.toPath().resolve(\"resources.arsc\").toFile();\nif (arsc.length() == 0) {\n    throw new IllegalArgumentException(\"resources.arsc is empty — APK artifact is truncated\");\n}\nparser.parse(new FileInputStream(arsc));","handlingStrategy":"validation","validationCode":"File arsc = new File(apkDir, \"resources.arsc\");\nif (!arsc.exists() || arsc.length() < 12) {\n    throw new IllegalArgumentException(\"resources.arsc missing/empty — artifact truncated\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    parser.parse(in);\n} catch (AndrolibException e) {\n    if (\"Input file is empty.\".equals(e.getMessage())) {\n        // re-fetch APK; artifact is truncated\n    }\n}","preventionTips":["Verify zip entry sizes (`unzip -v`) before extraction.","Checksum APKs after download.","Skip zero-byte resource entries in batch pipelines with a size pre-check."],"tags":["apktool","arsc","parsing","corrupt-file"],"backgroundTag":null,"analyzedSha":"79b63384d7d7e22917e6ea8b453272da7012515b","analyzedAt":"2026-08-14T10:43:28.812Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}