{"record":{"id":"23ba5e8e4da4487c","repo":"iBotPeaches/Apktool","slug":"could-not-read-aapt-binary-binfile-getpath","errorCode":null,"errorMessage":"Could not read aapt binary: \" + binFile.getPath()","messagePattern":"Could not read aapt binary: \" \\+ binFile\\.getPath\\(\\)","errorType":"exception","errorClass":"AndrolibException","httpStatus":null,"severity":"error","filePath":"brut.apktool/apktool-lib/src/main/java/brut/androlib/res/AaptManager.java","lineNumber":72,"sourceCode":"        binPath.append('/');\n        binPath.append(binName);\n        if (OSDetection.isWindows()) {\n            binPath.append(\".exe\");\n        }\n\n        File binFile;\n        try {\n            binFile = Jar.getResourceAsFile(AaptManager.class, binPath.toString(), binName + \"_\");\n        } catch (BrutException ex) {\n            throw new AndrolibException(ex);\n        }\n        setBinaryExecutable(binFile);\n        return binFile;\n    }\n\n    private static void setBinaryExecutable(File binFile) throws AndrolibException {\n        if (!binFile.isFile() || !binFile.canRead()) {\n            throw new AndrolibException(\"Could not read aapt binary: \" + binFile.getPath());\n        }\n        if (!binFile.setExecutable(true)) {\n            throw new AndrolibException(\"Could not set aapt binary as executable: \" + binFile.getPath());\n        }\n    }\n\n    public static int getBinaryVersion(File binFile) throws AndrolibException {\n        setBinaryExecutable(binFile);\n\n        String versionStr = OS.execAndReturn(new String[] { binFile.getPath(), \"version\" });\n        if (versionStr == null) {\n            throw new AndrolibException(\"Could not execute aapt binary at location: \" + binFile.getPath());\n        }\n\n        return getVersionFromString(versionStr);\n    }\n\n    public static int getVersionFromString(String versionStr) throws AndrolibException {","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/iBotPeaches/Apktool/blob/79b63384d7d7e22917e6ea8b453272da7012515b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/AaptManager.java#L54-L90","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Free space in / ensure the temp dir is writable: `df -h /tmp` and `touch /tmp/x`.","Set a writable temp dir: export TMPDIR=/var/tmp/apktool (create it first), or use -tp/--temp-path on the CLI.","Re-download the official apktool jar in case of corruption; whitelist the temp dir in antivirus."],"exampleFix":"# before\napktool b app   # /tmp full or noexec\n# after\nmkdir -p /var/tmp/apktool\napktool b app --temp-path /var/tmp/apktool","handlingStrategy":"validation","validationCode":"Path tmp = Paths.get(System.getProperty(\"java.io.tmpdir\"));\nif (!Files.isWritable(tmp)) {\n    System.setProperty(\"java.io.tmpdir\", \"/var/tmp/apktool\");\n    Files.createDirectories(Paths.get(\"/var/tmp/apktool\"));\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pre-flight check writable temp space before builds in CI.","Keep the apktool jar intact from official releases; avoid repackaging."],"tags":["apktool","aapt2","temp-dir","permissions","build"],"backgroundTag":null,"analyzedSha":"79b63384d7d7e22917e6ea8b453272da7012515b","analyzedAt":"2026-08-14T10:43:28.812Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}