iBotPeaches/Apktool · critical · AndrolibException

Input file is empty.

Error message

Input file is empty.

What it means

BinaryResourceParser.parse throws this when the very first attempt to read a chunk from resources.arsc hits end-of-stream, i.e. the supplied InputStream contains no resource-table data at all. It means the arsc input is zero-length or truncated to nothing before any chunk header.

Source

Thrown at brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/BinaryResourceParser.java:129

        return mHasCompactEntries;
    }

    public void enableCollectFlagsOffsets() {
        mEntrySpecFlagsOffsets = new ArrayList<>();
    }

    public Collection<Pair<Long, Integer>> getEntrySpecFlagsOffsets() {
        return mEntrySpecFlagsOffsets;
    }

    public void parse(InputStream in) throws AndrolibException {
        reset();
        mIn = new BinaryDataInputStream(new BufferedInputStream(in));

        ResChunkPullParser parser = new ResChunkPullParser(mIn);
        try {
            if (!nextChunk(parser)) {
                throw new AndrolibException("Input file is empty.");
            }
            if (parser.chunkType() != ResChunkHeader.RES_TABLE_TYPE) {
                throw new AndrolibException("Unexpected chunk: " + parser.chunkName() + " (expected: RES_TABLE_TYPE)");
            }

            parseTable(parser);

            Log.d(TAG, "End of chunks at 0x%08x", mIn.position());

            // We can't use remaining() here, the length of the main stream is unknown.
            if (mIn.available() > 0) {
                Log.d(TAG, "Ignoring trailing data at 0x%08x.", mIn.position());
            }
        } catch (IOException ex) {
            throw new AndrolibException("Could not decode arsc file.", ex);
        }
    }

View on GitHub (pinned to 79b63384d7)

Solutions

  1. Verify the APK integrity: `unzip -l app.apk | grep resources.arsc` — the entry must have a non-zero size.
  2. Re-extract or re-download the APK and confirm `resources.arsc` is > 0 bytes before decoding.
  3. If you built the arsc yourself (aapt2/custom tool), check that step actually wrote table data.
  4. Open the file in a hex viewer: it must start with chunk type 0x0002 (RES_TABLE_TYPE) — an empty file confirms truncation.

Example fix

// before
parser.parse(apkDir.toPath().resolve("resources.arsc").toFile().toInputStream());

// after
File arsc = apkDir.toPath().resolve("resources.arsc").toFile();
if (arsc.length() == 0) {
    throw new IllegalArgumentException("resources.arsc is empty — APK artifact is truncated");
}
parser.parse(new FileInputStream(arsc));
Defensive patterns

Strategy: validation

Validate before calling

File arsc = new File(apkDir, "resources.arsc");
if (!arsc.exists() || arsc.length() < 12) {
    throw new IllegalArgumentException("resources.arsc missing/empty — artifact truncated");
}

Try / catch

try {
    parser.parse(in);
} catch (AndrolibException e) {
    if ("Input file is empty.".equals(e.getMessage())) {
        // re-fetch APK; artifact is truncated
    }
}

Prevention

When it happens

Trigger: Calling `parse(InputStream)` with an empty or truncated resources.arsc — e.g. an APK rebuilt with a broken packaging step, a 0-byte arsc extracted by a faulty unzip, or passing the wrong stream to the parser.

Common situations: Repackaging pipelines that produce empty resources.arsc; CI jobs where the artifact download was interrupted; manual extraction where the arsc got clobbered; feeding a compressed-but-not-inflated stream.

Related errors


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