iBotPeaches/Apktool · critical · IOException

Input file is empty.

Error message

Input file is empty.

What it means

BinaryXmlResourceParser.setInput throws (as IOException, wrapped at [32]) when the input stream for a binary XML file (AXML) yields no chunk at all — the file is empty. This is the AXML counterpart of the arsc 'Input file is empty.' error.

Source

Thrown at brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/BinaryXmlResourceParser.java:116

    }

    @Override
    public void setInput(Reader in) throws XmlPullParserException {
        throw new XmlPullParserException(NOT_SUPPORTED);
    }

    @Override
    public void setInput(InputStream inputStream, String inputEncoding) throws XmlPullParserException {
        if (inputEncoding != null) {
            throw new XmlPullParserException(NOT_SUPPORTED);
        }

        reset();
        mIn = new BinaryDataInputStream(new BufferedInputStream(inputStream));
        mParser = new ResChunkPullParser(mIn);
        try {
            if (!nextChunk()) {
                throw new IOException("Input file is empty.");
            }
            if (mParser.chunkType() != ResChunkHeader.RES_XML_TYPE) {
                throw new IOException("Unexpected chunk: " + mParser.chunkName() + " (expected: RES_XML_TYPE)");
            }
        } catch (IOException ex) {
            mIn = null;
            mParser = null;
            throw new XmlPullParserException("Could not initialize parser.", this, ex);
        }

        mParser = new ResChunkPullParser(mIn, mParser.dataSize());
    }

    @Override
    public String getInputEncoding() {
        return null;
    }

View on GitHub (pinned to 79b63384d7)

Solutions

  1. Check the file size of the AXML before parsing; a valid one is at least a few dozen bytes.
  2. Re-pull or re-extract the file and verify non-zero size and a leading 0x0003 chunk type.
  3. If the entry is empty inside the APK itself (`unzip -l`), the APK is corrupt — re-obtain it.
  4. Guard batch jobs to skip/log empty files instead of feeding them to the parser.

Example fix

// before
parser.setInput(new FileInputStream(axmlFile), null);

// after
if (axmlFile.length() == 0) {
    throw new IllegalArgumentException("AXML file is empty: " + axmlFile);
}
parser.setInput(new FileInputStream(axmlFile), null);
Defensive patterns

Strategy: validation

Validate before calling

if (axmlFile.length() == 0) {
    throw new IllegalArgumentException("AXML empty: " + axmlFile);
}
try (RandomAccessFile raf = new RandomAccessFile(axmlFile, "r")) {
    int b0 = raf.read(), b1 = raf.read();
    if (b0 != 0x03 || b1 != 0x00) throw new IllegalArgumentException("Not binary XML");
}

Try / catch

try {
    parser.setInput(new FileInputStream(f), null);
} catch (XmlPullParserException e) {
    if (e.getCause() != null && e.getCause().getMessage().equals("Input file is empty.")) {
        // re-extract the file
    }
}

Prevention

When it happens

Trigger: Calling setInput() with a zero-length stream: an empty layout XML, a truncated AndroidManifest.xml pulled from a broken extraction, or a wrongly-resolved path that opened /dev/null-like empty file.

Common situations: ADB pulls interrupted midway leaving 0-byte XML files; repack tools emitting empty AXML entries; automated pipelines iterating over a directory where some files failed to extract.

Related errors


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