{"record":{"id":"3428e99954b546f0","repo":"skylot/jadx","slug":"expected-0x-actual-0x-offset-0x","errorCode":null,"errorMessage":"{}, expected: 0x{}, actual: 0x{}, offset: 0x{}","messagePattern":"(.+?), expected: 0x(.+?), actual: 0x(.+?), offset: 0x(.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"jadx-core/src/main/java/jadx/core/xmlgen/ParserStream.java","lineNumber":120,"sourceCode":"\t\treturn pos;\n\t}\n\n\tpublic void checkInt8(int expected, String error) throws IOException {\n\t\tint v = readInt8();\n\t\tif (v != expected) {\n\t\t\tthrowException(error, expected, v);\n\t\t}\n\t}\n\n\tpublic void checkInt16(int expected, String error) throws IOException {\n\t\tint v = readInt16();\n\t\tif (v != expected) {\n\t\t\tthrowException(error, expected, v);\n\t\t}\n\t}\n\n\tprivate void throwException(String error, int expected, int actual) throws IOException {\n\t\tthrow new IOException(error\n\t\t\t\t+ \", expected: 0x\" + Integer.toHexString(expected)\n\t\t\t\t+ \", actual: 0x\" + Integer.toHexString(actual)\n\t\t\t\t+ \", offset: 0x\" + Long.toHexString(getPos()));\n\t}\n\n\tpublic void checkPos(long expectedOffset, String error) throws IOException {\n\t\tif (getPos() != expectedOffset) {\n\t\t\tthrow new IOException(error + \", expected offset: 0x\" + Long.toHexString(expectedOffset)\n\t\t\t\t\t+ \", actual: 0x\" + Long.toHexString(getPos()));\n\t\t}\n\t}\n\n\tpublic void skipToPos(long expectedOffset, String error) throws IOException {\n\t\tlong pos = getPos();\n\t\tif (pos > expectedOffset) {\n\t\t\tthrow new IOException(error + \", expected offset not reachable: 0x\" + Long.toHexString(expectedOffset)\n\t\t\t\t\t+ \", actual: 0x\" + Long.toHexString(getPos()));\n\t\t}","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/skylot/jadx/blob/e738a26571d02919f01df40de93bc9a44dee4e18/jadx-core/src/main/java/jadx/core/xmlgen/ParserStream.java#L102-L138","documentation":"ParserStream.throwException is invoked by checkInt8/checkInt16 when a read magic/value does not match an expected constant. The message includes the expected and actual hex values plus the current offset, giving precise diagnostics for structural validation failures in Android binary resource headers.","triggerScenarios":"checkInt16(expected, error) or checkInt8(expected, error) reads a value and compares it to a hard-coded constant (e.g., header size 0x0010, magic bytes). A mismatch means the binary structure does not conform to the expected Android resource format at that offset. Common callers: parseTypeSpecChunk (header size 0x0010), parseLibraryTypeChunk (header size 12), parseValue (size 8, res0 0).","commonSituations":"Parsing a binary XML or resource table produced by a non-standard or newer Android build tool that changed header layout. File corruption flipping bytes in the header. Passing a raw class file or PNG as if it were resources.arsc. Obfuscated apps with intentionally mangled resource headers.","solutions":["Verify the file is genuinely an Android binary resource file (resources.arsc or *.axml)","Re-extract the resource from the APK to rule out corruption","Upgrade jadx to a version that supports the resource format variant you encountered","File a jadx bug report including the offset, expected, and actual values from the error"],"exampleFix":"// Validate file type before decoding:\nbyte[] magic = Files.readAllBytes(path);\nif (magic.length < 4 || magic[0] != 0x02 || magic[1] != 0x00) {\n    throw new IllegalArgumentException(\"Not a valid Android binary resource\");\n}","handlingStrategy":"validation","validationCode":"// Sniff the first bytes to confirm Android binary resource format:\nbyte[] head = new byte[4];\ntry (InputStream is = Files.newInputStream(path)) {\n    is.read(head);\n}\nboolean isBinaryRes = (head[0] & 0xFF) == 0x02 && (head[1] & 0xFF) == 0x00;\nif (!isBinaryRes) { /* not a valid AXML/arsc */ }","typeGuard":null,"tryCatchPattern":"try {\n    parser.decode(stream);\n} catch (IOException e) {\n    if (e.getMessage().contains(\"expected: 0x\")) {\n        LOG.warn(\"Format mismatch, skipping resources\", e);\n    }\n}","preventionTips":["Validate the resource file type before parsing","Keep jadx updated for new format support","Use aapt/apktool as a cross-check for valid resources"],"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"}