{"record":{"id":"ef29283501ea50a2","repo":"shwenzhang/AndResGuard","slug":"expected-0x-08x-got-0x-08x-extdataoutput","errorCode":null,"errorMessage":"Expected: 0x%08x, got: 0x%08x","messagePattern":"Expected: 0x%08x, got: 0x%08x","errorType":"exception","errorClass":"java.io.IOException","httpStatus":null,"severity":"error","filePath":"AndResGuard-core/src/main/java/com/tencent/mm/util/ExtDataOutput.java","lineNumber":29,"sourceCode":"  }\n\n  public void writeIntArray(int[] array) throws IOException {\n    int length = array.length;\n    for (int i = 0; i < length; i++) {\n      writeInt(array[i]);\n    }\n  }\n\n  public void writeBytes(ExtDataInput in, int length) throws IOException {\n    byte[] data = new byte[length];\n    in.readFully(data);\n    write(data);\n  }\n\n  public void writeCheckInt(int value, int expected) throws IOException {\n    writeInt(value);\n    if (value != expected) {\n      throw new IOException(String.format(\"Expected: 0x%08x, got: 0x%08x\", expected, value));\n    }\n  }\n\n  public void writeCheckChunkTypeInt(ExtDataInput reader, int expected, int possible) throws IOException {\n    int value = reader.readInt();\n    writeInt(value);\n    if (value == possible) {\n      writeCheckChunkTypeInt(reader, expected, -1);\n    } else if (value != expected) {\n      throw new IOException(String.format(\"Expected: 0x%08x, got: 0x%08x\", expected, value));\n    }\n  }\n\n  public void writeCheckShort(short value, short expected) throws IOException {\n    writeShort(value);\n    if (value != expected) {\n      throw new IOException(String.format(\"Expected: 0x%08x, got: 0x%08x\", expected, value));\n    }","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/shwenzhang/AndResGuard/blob/e4df245d82f27d9a2d0dd108260a3510cbaba849/AndResGuard-core/src/main/java/com/tencent/mm/util/ExtDataOutput.java#L11-L47","documentation":"ExtDataOutput.writeCheckInt writes a 4-byte int then throws IOException if it differs from expected. Used when re-serializing the resource table (writeSpecNameStringBlock, writeTableNameStringBlock): if the value the writer computes is not what the schema dictates, the resource table would be malformed, so it aborts.","triggerScenarios":"Writing the string/spec-name table where a computed value (count, offset, index) does not equal the expected constant — usually a bug or data-dependent mismatch during resource shrinking/rewriting.","commonSituations":"Resource names containing unusual characters or extremely large tables pushing computed offsets out of sync; AndResGuard bugs with certain resource table layouts.","solutions":["Report/reproduce with the failing APK; try the latest AndResGuard version where such writer bugs may be fixed","Reduce resource table complexity (rename problematic resources) to see if a specific entry triggers it","Disable resource shrinking (whiteList adjustments) to isolate which resources trigger the mismatch","Compare the written value vs expected in the message to locate the diverging field"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    output.writeCheckInt(value, expected);\n} catch (IOException e) {\n    if (e.getMessage().startsWith(\"Expected:\")) {\n        throw new IOException(\"Writer invariant violated while building string block: \" + e.getMessage(), e);\n    }\n    throw e;\n}","preventionTips":["Use a recent AndResGuard release with writer fixes","Test resource shrinking on representative APKs in CI","Avoid exotic resource names/very large tables when possible; bisect offending resources on failure"],"tags":["java","io","serialization","arsc"],"backgroundTag":"internal-invariant-violation","analyzedSha":"e4df245d82f27d9a2d0dd108260a3510cbaba849","analyzedAt":"2026-09-12T17:49:07.798Z","contentChangedAt":"2026-09-12T17:49:07.798Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}