{"record":{"id":"f792ad4ba3f1d491","repo":"iBotPeaches/Apktool","slug":"could-not-decode-arsc-file","errorCode":null,"errorMessage":"Could not decode arsc file.","messagePattern":"Could not decode arsc file\\.","errorType":"exception","errorClass":"AndrolibException","httpStatus":null,"severity":"critical","filePath":"brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/BinaryResourceParser.java","lineNumber":144,"sourceCode":"        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\n    public void reset() {\n        mIn = null;\n        mMissingEntrySpecs.clear();\n        mInvalidConfigs.clear();\n        mValueStringPool = null;\n        mPackageCount = 0;\n        mPackage = null;\n        mTypeIdOffset = 0;\n        mTypeStringPool = null;\n        mKeyStringPool = null;\n        mHasSparseEntries = false;\n        mHasCompactEntries = false;\n        if (mEntrySpecFlagsOffsets != null) {\n            mEntrySpecFlagsOffsets.clear();\n        }","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/iBotPeaches/Apktool/blob/79b63384d7d7e22917e6ea8b453272da7012515b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/BinaryResourceParser.java#L126-L162","documentation":"Catch-all thrown by BinaryResourceParser.parse when an IOException (other than the structured empty/invalid-chunk checks) escapes while reading the resource table. The original IOException is chained as the cause. It almost always means the arsc is truncated or unreadable at the byte level.","triggerScenarios":"An IOException raised inside parseTable (e.g. EOF while reading a string pool, config, or entry) because the declared chunk sizes exceed the actual file length; or a genuine stream failure (closed stream, disk error) while parsing.","commonSituations":"Partially downloaded APKs; arsc truncated by a repack tool that rewrote sizes; reading from a network stream that dropped mid-parse; zip entry read failures.","solutions":["Read the chained cause — an EOFException-like failure means truncation, other IOExceptions point to the stream/disk.","Re-download or re-extract the APK and verify its checksum before decoding.","Validate the arsc length against the zip central directory entry size (`unzip -v app.apk`).","If the file is intentionally patched/obfuscated, compare with the original from the store/device to see which chunk overruns."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// fully materialize before parsing to rule out stream issues\nbyte[] data = Files.readAllBytes(arscPath);\nif (data.length < 12) throw new IllegalArgumentException(\"arsc truncated\");","typeGuard":null,"tryCatchPattern":"try {\n    parser.parse(new ByteArrayInputStream(data));\n} catch (AndrolibException e) {\n    if (\"Could not decode arsc file.\".equals(e.getMessage())) {\n        Throwable cause = e.getCause(); // EOF => truncation; other IOException => stream/disk\n    }\n}","preventionTips":["Parse from byte arrays, not live streams.","Verify artifact checksums after download.","Compare arsc actual size against the zip central directory entry."],"tags":["apktool","arsc","parsing","io","truncated-file"],"backgroundTag":null,"analyzedSha":"79b63384d7d7e22917e6ea8b453272da7012515b","analyzedAt":"2026-08-14T10:43:28.812Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}