iBotPeaches/Apktool · critical · EOFException
Unexpected EOF while skipping chunk.
Error message
Unexpected EOF while skipping chunk.
What it means
Thrown by ResChunkPullParser.skipChunk() when the underlying stream raises EOFException while skipping to the chunk's declared end. The chunk header promised more bytes than the stream actually contains, so the file is truncated relative to its own metadata. It is a hard signal that the binary resource file (resources.arsc, binary XML, etc.) is cut short.
Source
Thrown at brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/ResChunkPullParser.java:165
}
}
public int skipChunk() throws IOException {
if (mChunkHeader == null) {
throw new IllegalStateException();
}
try {
long position = mIn.position();
long chunkEnd = chunkEnd();
if (position == chunkEnd) {
return 0;
}
if (position > chunkEnd) {
throw new IOException("Stream advanced past chunk end.");
}
return mIn.skipBytes((int) (chunkEnd - position));
} catch (EOFException ignored) {
throw new EOFException("Unexpected EOF while skipping chunk.");
} catch (IOException ex) {
throw new IOException("Error while skipping chunk.", ex);
}
}
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.");
}View on GitHub (pinned to 79b63384d7)
Solutions
- Verify the APK integrity first: re-download or re-copy the file and check its zip CRCs (e.g. unzip -t app.apk).
- Compare file length against the chunk's declared end (chunkStart() + chunkSize()) before skipping; if it exceeds the file size, reject the file as truncated.
- If you must proceed, catch EOFException and treat the resource file as broken rather than retrying (apktool's --keep-broken-resources flag relaxes some of this during decode).
Defensive patterns
Strategy: try-catch
Validate before calling
// Before parsing, check the file is at least as long as the chunk claims
long chunkEnd = parser.chunkStart() + parser.chunkSize();
if (chunkEnd > fileSize) {
throw new IOException("Truncated file: chunk ends at " + chunkEnd + " but file is " + fileSize);
} Try / catch
try {
parser.skipChunk();
} catch (EOFException ex) {
// "Unexpected EOF while skipping chunk." -> file truncated; mark resource as broken, do not retry
markResourceBroken();
} Prevention
- Verify APK integrity (unzip -t / CRC check) before decoding
- Re-download partially transferred files instead of parsing them
- Treat EOF during skip as terminal for that file, not a retryable condition
When it happens
Trigger: An APK truncated by an interrupted download or partial copy; a resources.arsc whose final chunk declares a size extending past the actual file; reading from a ZipRODirectory entry whose compressed data is cut off; memory-truncated streams in tests.
Common situations: Decoding an APK that failed to download completely; files extracted with a tool that stopped on a zip error; APKs served over flaky CI artifact storage; zip entries with bad CRC trimmed by 'repair' tools.
Related errors
- Unexpected EOF while skipping chunk header.
- 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/759304f7e9b7f8d6.
Report an issue: GitHub.