{"record":{"id":"a5a9b8bfc4617d18","repo":"skylot/jadx","slug":"error-reading-type-spec-chunk-at-offset-0x-x","errorCode":null,"errorMessage":"Error reading type spec chunk at offset 0x%x","messagePattern":"Error reading type spec chunk at offset 0x%x","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"jadx-core/src/main/java/jadx/core/xmlgen/ResTableBinaryParser.java","lineNumber":221,"sourceCode":"\t\t\t\t\tLOG.warn(\"Unknown chunk type {} encountered at offset {}\", type, chunkStart);\n\t\t\t}\n\t\t}\n\t}\n\n\t@SuppressWarnings(\"unused\")\n\tprivate void parseTypeSpecChunk(long chunkStart) throws IOException {\n\t\tis.checkInt16(0x0010, \"Unexpected type spec header size\");\n\t\tint chunkSize = is.readInt32();\n\t\tlong expectedEndPos = chunkStart + chunkSize;\n\n\t\tint id = is.readInt8();\n\t\tis.skip(3);\n\t\tint entryCount = is.readInt32();\n\t\tfor (int i = 0; i < entryCount; i++) {\n\t\t\tint entryFlag = is.readInt32();\n\t\t}\n\t\tif (is.getPos() != expectedEndPos) {\n\t\t\tthrow new IOException(String.format(\"Error reading type spec chunk at offset 0x%x\", chunkStart));\n\t\t}\n\t}\n\n\tprivate void parseLibraryTypeChunk(long chunkStart) throws IOException {\n\t\tLOG.trace(\"parsing library type chunk starting at offset {}\", chunkStart);\n\t\tis.checkInt16(12, \"Unexpected header size\");\n\t\tint chunkSize = is.readInt32();\n\t\tlong expectedEndPos = chunkStart + chunkSize;\n\t\tint count = is.readInt32();\n\t\tfor (int i = 0; i < count; i++) {\n\t\t\tint packageId = is.readInt32();\n\t\t\tString packageName = is.readString16Fixed(128);\n\t\t\tLOG.info(\"Found resource shared library {}, pkgId: {}\", packageName, packageId);\n\t\t\tif (is.getPos() > expectedEndPos) {\n\t\t\t\tthrow new IOException(\"reading after chunk end\");\n\t\t\t}\n\t\t}\n\t\tif (is.getPos() != expectedEndPos) {","sourceCodeStart":203,"sourceCodeEnd":239,"githubUrl":"https://github.com/skylot/jadx/blob/e738a26571d02919f01df40de93bc9a44dee4e18/jadx-core/src/main/java/jadx/core/xmlgen/ResTableBinaryParser.java#L203-L239","documentation":"After reading all entries in a type spec chunk (RES_TABLE_TYPE_SPEC_TYPE), the parser checks that the stream position equals the expected end (chunkStart + chunkSize). A mismatch means the declared chunk size does not match the bytes actually consumed by the entryCount flags.","triggerScenarios":"parseTypeSpecChunk reads headerSize (validated 0x0010), chunkSize, id, 3 skip bytes, entryCount, then entryCount × 4-byte flags. If getPos() != chunkStart + chunkSize afterward, this IOException is thrown. The discrepancy indicates the entryCount or chunkSize field is inconsistent with the actual data.","commonSituations":"Obfuscated resources.arsc where entryCount is inflated or deflated. Corrupt resource table from a damaged APK. Custom packers that restructure resource chunks. Newer format with additional trailing fields jadx does not read.","solutions":["Re-extract resources.arsc from a clean APK","Upgrade jadx to the latest version","Report the file to jadx with the chunk offset from the error","Use jadx --no-res to bypass resource decoding"],"exampleFix":"// Skip resource decoding as a workaround:\njadxArgs.setSkipResources(true);","handlingStrategy":"try-catch","validationCode":"// Verify APK integrity via zip CRC before parsing resources\nZipFile zf = new ZipFile(apk);\nzf.getInputStream(zf.getEntry(\"resources.arsc\")).transferTo(OutputStream.nullOutputStream()); // throws on CRC mismatch","typeGuard":null,"tryCatchPattern":"try {\n    resTableParser.decode(stream);\n} catch (IOException e) {\n    if (e.getMessage().contains(\"type spec chunk\")) {\n        LOG.warn(\"Type spec corruption, skipping resources\", e);\n        jadxArgs.setSkipResources(true);\n    }\n}","preventionTips":["Validate APK CRC/zip integrity before resource parsing","Maintain a --no-res fallback","Report corrupt-but-interesting files to jadx"],"tags":["android","binary-parsing","validation","resource-table","corrupt-input"],"backgroundTag":null,"analyzedSha":"e738a26571d02919f01df40de93bc9a44dee4e18","analyzedAt":"2026-08-14T00:10:24.238Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}