iBotPeaches/Apktool · error · IOException
Error while skipping chunk header.
Error message
Error while skipping chunk header.
What it means
Generic wrapper thrown by ResChunkPullParser.skipHeader() for non-EOF IOExceptions raised while skipping the header bytes; the original exception is attached as the cause. The 'Stream advanced past chunk header end.' throw at ResChunkPullParser.java:182 is inside the try, so it also surfaces wrapped here with its message only on the cause chain.
Source
Thrown at brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/ResChunkPullParser.java:188
public int skipHeader() throws IOException {
if (mChunkHeader == null) {
throw new IllegalStateException();
}
try {
long position = mIn.position();
long headerEnd = headerEnd();
if (position == headerEnd) {
return 0;
}
if (position > headerEnd) {
throw new IOException("Stream advanced past chunk header end.");
}
return mIn.skipBytes((int) (headerEnd - position));
} catch (EOFException ignored) {
throw new EOFException("Unexpected EOF while skipping chunk header.");
} catch (IOException ex) {
throw new IOException("Error while skipping chunk header.", ex);
}
}
}
View on GitHub (pinned to 79b63384d7)
Solutions
- Unwrap ex.getCause() to distinguish 'advanced past header end' (logic error / bad headerSize) from genuine I/O failures.
- Only call skipHeader() before any header consumption, once per chunk.
- Keep exclusive ownership of the BinaryDataInputStream during parsing.
Defensive patterns
Strategy: try-catch
Try / catch
try {
parser.skipHeader();
} catch (IOException ex) {
Throwable cause = ex.getCause();
if (cause != null && cause.getMessage().contains("chunk header end")) {
// header was already consumed -> fix calling code
} else {
// I/O failure on backing stream
}
} Prevention
- Unwrap the cause before deciding on a fix
- Never interleave manual header reads with skipHeader()
- Close streams only after the parser loop finishes
When it happens
Trigger: position > headerEnd when skipHeader() is called (wrapped error 43); underlying stream already closed; I/O errors on the backing file or zip entry during the skip.
Common situations: Custom chunk-header reads followed by skipHeader(); sharing the input stream between components; corrupt APKs with rewritten headerSize fields.
Related errors
- Error while skipping chunk.
- Stream advanced past chunk end.
- Unexpected EOF while skipping chunk.
- Stream advanced past chunk header end.
- Unexpected EOF while skipping chunk header.
AI-assisted analysis of iBotPeaches/Apktool@79b63384d7 (2026-08-14).
Data as JSON: /api/errors/d57ff6367a1cce5a.
Report an issue: GitHub.