shwenzhang/AndResGuard · error · brut.androlib.AndrolibException
Invalid chunk type: expected=0x%08x, got=0x%08x
Error message
Invalid chunk type: expected=0x%08x, got=0x%08x
What it means
ARSCDecoder.checkChunkType verifies that the chunk header just read from resources.arsc has the expected chunk type constant (e.g. table, package, type spec). A mismatch means the arsc stream structure differs from what the decoder expects — either the file is corrupt, uses an unknown format version, or a previous chunk was parsed with the wrong length so the reader is now mid-stream.
Solutions
- Upgrade AndResGuard to support newer arsc chunk formats
- Rebuild the APK with the standard Android build tools (aapt/aapt2)
- Validate the input APK with aapt dump resources; re-obtain a clean copy if corrupt
- Check that no other resource-processing tool ran before AndResGuard
Example fix
// before: AndResGuard 1.2.x on an APK built with new AGP/aapt2
// after: bump the gradle dependency
classpath('com.tencent.mm:AndResGuard-gradle-plugin:1.2.21') Defensive patterns
Strategy: try-catch
Validate before calling
// pre-flight: dump the arsc chunk structure with aapt before processing // aapt dump resources app.apk > /dev/null || fail "invalid resources.arsc"
Try / catch
try {
decodeArsc(arscStream);
} catch (AndrolibException e) {
if (e.getMessage().startsWith("Invalid chunk type")) {
// usually a format/tooling mismatch — upgrade tooling or rebuild, not a retry
throw new IllegalStateException("Unsupported or corrupt arsc chunk layout; rebuild with official aapt2", e);
}
throw e;
} Prevention
- Use a current Android SDK/AGP and current AndResGuard together
- Verify APK integrity with aapt dump before processing
- Avoid tools that reorder or rewrite arsc chunks upstream
- Treat this as non-retryable: rebuild the input instead
When it happens
Trigger: nextChunk() reads a header whose type field differs from expectedType during decode of the table, package, type-spec or config stages — triggered by corrupted arsc files, arsc with unsupported chunk types, or misaligned reads after an earlier malformed chunk.
Common situations: APKs processed by other tools that restructure resources.arsc, APKs built with very new aapt2 chunk types older AndResGuard doesn't know, or partially downloaded/corrupted APKs.
Related errors
- Invalid chunk type: expected=0x%08x, got=0x%08x
- Invalid chunk type: expected=
- Config size < 28
- readAndWriteHeader size < 0: size=
- Could not decode arsc file
AI-assisted analysis of shwenzhang/AndResGuard@e4df245d82 (2026-09-12).
Data as JSON: /api/errors/702cdc6ce89b59af.
Report an issue: GitHub.
Appendix: source
Thrown at AndResGuard-core/src/main/java/com/tencent/mm/androlib/res/decoder/ARSCDecoder.java:973
private void writeConfigFlags() throws IOException, AndrolibException {
//总的有多大
int size = mIn.readInt();
if (size < 28) {
throw new AndrolibException("Config size < 28");
}
mOut.writeInt(size);
mOut.writeBytes(mIn, size - 4);
}
private Header nextChunk() throws IOException {
return mHeader = Header.read(mIn);
}
private void checkChunkType(int expectedType) throws AndrolibException {
if (mHeader.type != expectedType) {
throw new AndrolibException(String.format("Invalid chunk type: expected=0x%08x, got=0x%08x",
expectedType,
mHeader.type
));
}
}
private void nextChunkCheckType(int expectedType) throws IOException, AndrolibException {
nextChunk();
checkChunkType(expectedType);
}
private Header writeNextChunk(int diffSize) throws IOException, AndrolibException {
mHeader = Header.readAndWriteHeader(mIn, mOut, diffSize);
return mHeader;
}
private Header writeNextChunkCheck(int expectedType, int diffSize) throws IOException, AndrolibException {
mHeader = Header.readAndWriteHeader(mIn, mOut, diffSize);View on GitHub (pinned to e4df245d82)