iBotPeaches/Apktool · error · AndrolibException

Could not read aapt binary: " + binFile.getPath()

Error message

Could not read aapt binary: " + binFile.getPath()

What it means

AndrolibException from AaptManager.setBinaryExecutable() when the aapt2 binary file extracted from the jar either is not a regular file or cannot be read. getBinaryFile() extracts the bundled aapt2 to a temp location (prefixed aapt2_) via Jar.getResourceAsFile; if that extraction failed silently, the temp dir filled up, or permissions were dropped, the subsequent isFile()/canRead() check fails and the build aborts.

Source

Thrown at brut.apktool/apktool-lib/src/main/java/brut/androlib/res/AaptManager.java:72

        binPath.append('/');
        binPath.append(binName);
        if (OSDetection.isWindows()) {
            binPath.append(".exe");
        }

        File binFile;
        try {
            binFile = Jar.getResourceAsFile(AaptManager.class, binPath.toString(), binName + "_");
        } catch (BrutException ex) {
            throw new AndrolibException(ex);
        }
        setBinaryExecutable(binFile);
        return binFile;
    }

    private static void setBinaryExecutable(File binFile) throws AndrolibException {
        if (!binFile.isFile() || !binFile.canRead()) {
            throw new AndrolibException("Could not read aapt binary: " + binFile.getPath());
        }
        if (!binFile.setExecutable(true)) {
            throw new AndrolibException("Could not set aapt binary as executable: " + binFile.getPath());
        }
    }

    public static int getBinaryVersion(File binFile) throws AndrolibException {
        setBinaryExecutable(binFile);

        String versionStr = OS.execAndReturn(new String[] { binFile.getPath(), "version" });
        if (versionStr == null) {
            throw new AndrolibException("Could not execute aapt binary at location: " + binFile.getPath());
        }

        return getVersionFromString(versionStr);
    }

    public static int getVersionFromString(String versionStr) throws AndrolibException {

View on GitHub (pinned to 79b63384d7)

Solutions

  1. Free space in / ensure the temp dir is writable: `df -h /tmp` and `touch /tmp/x`.
  2. Set a writable temp dir: export TMPDIR=/var/tmp/apktool (create it first), or use -tp/--temp-path on the CLI.
  3. Re-download the official apktool jar in case of corruption; whitelist the temp dir in antivirus.

Example fix

# before
apktool b app   # /tmp full or noexec
# after
mkdir -p /var/tmp/apktool
apktool b app --temp-path /var/tmp/apktool
Defensive patterns

Strategy: validation

Validate before calling

Path tmp = Paths.get(System.getProperty("java.io.tmpdir"));
if (!Files.isWritable(tmp)) {
    System.setProperty("java.io.tmpdir", "/var/tmp/apktool");
    Files.createDirectories(Paths.get("/var/tmp/apktool"));
}

Prevention

When it happens

Trigger: Resource extraction from the apktool jar failing (corrupt jar, unreadable jar packaging); temp directory (/tmp) full or mounted noexec/read-only so the extracted file is not a readable regular file; antivirus quarantining the extracted binary on Windows.

Common situations: Disk-full /tmp in CI; hardened Docker images with a read-only tmpfs; a repackaged or corrupted apktool jar; security software removing the extracted aapt2.

Related errors


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