{"record":{"id":"807bd05cb7919217","repo":"iBotPeaches/Apktool","slug":"legacy-aapt-is-no-longer-supported","errorCode":null,"errorMessage":"Legacy aapt is no longer supported.","messagePattern":"Legacy aapt is no longer supported\\.","errorType":"exception","errorClass":"AndrolibException","httpStatus":null,"severity":"error","filePath":"brut.apktool/apktool-cli/src/main/java/brut/apktool/Main.java","lineNumber":585,"sourceCode":"            config.setNoApk(true);\n        }\n        if (cli.hasOption(buildNoCrunchOption)) {\n            config.setNoCrunch(true);\n        }\n        if (cli.hasOption(buildCopyOriginalOption)) {\n            config.setCopyOriginal(true);\n        }\n        if (cli.hasOption(buildDebuggableOption)) {\n            config.setDebuggable(true);\n        }\n        if (cli.hasOption(buildNetSecConfOption)) {\n            config.setNetSecConf(true);\n        }\n        if (cli.hasOption(buildAaptOption)) {\n            try {\n                String aaptBinary = cli.getOptionValue(buildAaptOption);\n                if (AaptManager.getBinaryVersion(new File(aaptBinary)) == 1) {\n                    throw new AndrolibException(\"Legacy aapt is no longer supported.\");\n                }\n\n                config.setAaptBinary(aaptBinary);\n            } catch (AndrolibException ex) {\n                System.err.println(ex.getMessage());\n                System.exit(1);\n                return;\n            }\n        }\n\n        File outFile = null;\n        if (cli.hasOption(buildOutputOption)) {\n            if (cli.hasOption(buildNoApkOption)) {\n                printOptionConflict(buildOutputOption, buildNoApkOption);\n            } else {\n                outFile = new File(cli.getOptionValue(buildOutputOption));\n            }\n        }","sourceCodeStart":567,"sourceCodeEnd":603,"githubUrl":"https://github.com/iBotPeaches/Apktool/blob/79b63384d7d7e22917e6ea8b453272da7012515b/brut.apktool/apktool-cli/src/main/java/brut/apktool/Main.java#L567-L603","documentation":"Thrown (as an AndrolibException) by the apktool CLI when the user supplies a custom aapt binary via --aapt and that binary reports version 1. Apktool only supports aapt2; the legacy aapt was removed because modern resource tables (resources.arsc v2+) cannot be rebuilt with it. The CLI catches the exception, prints the message, and exits with code 1.","triggerScenarios":"Running `apktool b app-dir --aapt /path/to/old/aapt` where `aapt version` prints a string starting with \"Android Asset Packaging Tool, v0.\" (parsed as version 1 by AaptManager.getVersionFromString). Also triggered when the given path is an old SDK build-tools aapt binary instead of aapt2.","commonSituations":"Scripts or CI setups written against apktool 2.x that pinned an old build-tools aapt path; upgrading apktool to a version that dropped aapt1 support; pointing --aapt at the wrong file inside build-tools (aapt vs aapt2).","solutions":["Remove the --aapt option entirely and let apktool use its bundled aapt2 (recommended).","Point --aapt at an aapt2 binary (e.g. $ANDROID_HOME/build-tools/<ver>/aapt2) and verify it prints `aapt2 version` output like \"Android Asset Packaging Tool (aapt) 2:\".","Update the SDK build-tools to 26.0.2+ so the binary identifies itself as aapt2."],"exampleFix":"# before\napktool b dist/myapp -o myapp.apk --aapt /opt/sdk/build-tools/25.0.3/aapt\n# after\napktool b dist/myapp -o myapp.apk\n# or, if a custom binary is required:\napktool b dist/myapp -o myapp.apk --aapt /opt/sdk/build-tools/33.0.0/aapt2","handlingStrategy":"validation","validationCode":"// Before passing --aapt, probe the binary yourself\nString out = OS.execAndReturn(new String[]{aaptPath, \"version\"});\nif (out == null || !out.startsWith(\"Android Asset Packaging Tool (aapt) 2\")) {\n    throw new IllegalArgumentException(\"Not a usable aapt2 binary: \" + aaptPath);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not pin --aapt to old build-tools paths in scripts; prefer the bundled aapt2.","Assert `aapt2 version` output starts with 'Android Asset Packaging Tool (aapt) 2' in CI before invoking apktool."],"tags":["apktool","aapt","android","cli","version-mismatch"],"backgroundTag":null,"analyzedSha":"79b63384d7d7e22917e6ea8b453272da7012515b","analyzedAt":"2026-08-14T10:43:28.812Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}