iBotPeaches/Apktool · error · IOException

Error while skipping chunk.

Error message

Error while skipping chunk.

What it means

Generic wrapper thrown by ResChunkPullParser.skipChunk() for any IOException raised while skipping bytes to the chunk end that is not an EOFException. It preserves the original exception as the cause. Because the sibling 'Stream advanced past chunk end.' throw at ResChunkPullParser.java:161 sits inside this same try block, that error also surfaces wrapped here, with its message visible only via getCause().

Source

Thrown at brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/ResChunkPullParser.java:167

    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.");
            }
            return mIn.skipBytes((int) (headerEnd - position));
        } catch (EOFException ignored) {

View on GitHub (pinned to 79b63384d7)

Solutions

  1. Inspect ex.getCause(): if it is 'Stream advanced past chunk end.', a nested read consumed too much or the chunk size field is wrong; if EOF, the file is truncated.
  2. Ensure nothing else closes or reads the BinaryDataInputStream while the parser owns it.
  3. Validate chunk sizes against the real file length before parsing chunks you do not trust.
  4. Treat unrecoverable cases as 'broken resource file' and skip that file with a warning, mirroring apktool's keep-broken-resources behavior.
Defensive patterns

Strategy: try-catch

Try / catch

try {
    parser.skipChunk();
} catch (IOException ex) {
    Throwable cause = ex.getCause();
    if (cause instanceof EOFException) { /* truncated file */ }
    else if (cause != null && cause.getMessage().contains("Stream advanced past chunk end")) { /* overrun bug or bad size field */ }
    else { /* genuine I/O failure on backing store */ }
}

Prevention

When it happens

Trigger: Any I/O failure inside mIn.skipBytes(): position > chunkEnd (the wrapped error 40), closed underlying stream, disk read errors on an extracted temp file, or a defective zip entry stream.

Common situations: Decoding corrupt or obfuscated APKs; streams closed early by another component; nested parsers reading more than the chunk allowed; filesystem issues on the temp extraction directory.

Related errors


AI-assisted analysis of iBotPeaches/Apktool@79b63384d7 (2026-08-14). Data as JSON: /api/errors/db2e1e7fa09302d2. Report an issue: GitHub.