iBotPeaches/Apktool · critical · EOFException
Unexpected EOF while skipping chunk header.
Error message
Unexpected EOF while skipping chunk header.
What it means
Thrown by ResChunkPullParser.skipHeader() when the stream hits EOF while skipping to the end of the chunk header. The headerSize field promises more bytes than remain in the stream, so the file ends inside a chunk header — a definitively truncated or malformed binary resource file.
Source
Thrown at brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/ResChunkPullParser.java:186
}
}
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
- Verify the file is complete: check zip integrity (unzip -t) and re-obtain the APK if CRCs fail.
- Before parsing, ensure at least ResChunkHeader.SIZE bytes remain at the current offset when a new chunk is expected.
- Catch EOFException at the file-parsing level and mark that resource file as broken instead of aborting the whole decode.
Defensive patterns
Strategy: try-catch
Validate before calling
// Ensure enough bytes remain for the header before skipping
long headerEnd = parser.chunkStart() + parser.headerSize();
if (headerEnd > totalFileSize) {
throw new EOFException("File ends inside chunk header");
} Try / catch
try {
parser.skipHeader();
} catch (EOFException ex) {
// file truncated inside a chunk header; mark undecodable, no retry
} Prevention
- Check zip integrity before decoding so truncated entries are caught early
- Treat EOF in a header as a corrupt file, never as transient
- Keep source files immutable during decode (no concurrent writes)
When it happens
Trigger: A binary XML/resources.arsc file whose last bytes are cut off inside a chunk header; headerSize fields inflated by obfuscators; reading from a deflated zip entry whose stream ends early.
Common situations: Partially downloaded APKs; files corrupted in transfer or storage; header sizes rewritten by APK packing tools that pad incorrectly.
Related errors
- Unexpected EOF while skipping chunk.
- Stream advanced past chunk end.
- Error while skipping chunk.
- Stream advanced past chunk header end.
- Error while skipping chunk header.
AI-assisted analysis of iBotPeaches/Apktool@79b63384d7 (2026-08-14).
Data as JSON: /api/errors/48777eacd00459a8.
Report an issue: GitHub.