iBotPeaches/Apktool · error · AndrolibException
Could not identify aapt binary version:
Error message
Could not identify aapt binary version:
What it means
AndrolibException from AaptManager.getVersionFromString() when the output of `<aapt> version` does not match any known banner prefix. Apktool recognizes two aapt2 banner forms ("...(aapt) 2:" and "...(aapt) 2." pre-26.0.2) and one aapt1 form ("Android Asset Packaging Tool, v0."). Anything else — a wrapper script, a locale-modified banner, a shim that prints extra text — is unidentifiable and the build/refusing path aborts.
Source
Thrown at brut.apktool/apktool-lib/src/main/java/brut/androlib/res/AaptManager.java:100
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 {
if (versionStr.startsWith("Android Asset Packaging Tool (aapt) 2:")) {
return 2;
}
if (versionStr.startsWith("Android Asset Packaging Tool (aapt) 2.")) {
return 2; // Prior to Android SDK 26.0.2
}
if (versionStr.startsWith("Android Asset Packaging Tool, v0.")) {
return 1;
}
throw new AndrolibException("Could not identify aapt binary version: " + versionStr);
}
}
View on GitHub (pinned to 79b63384d7)
Solutions
- Run `<binary> version` yourself and confirm the first line starts with "Android Asset Packaging Tool (aapt) 2:"; if not, switch binaries.
- Remove wrapper scripts and point --aapt directly at the real binary from Android SDK build-tools.
- Use the bundled aapt2 (omit --aapt).
Example fix
# before apktool b app --aapt ./my-aapt-wrapper.sh # after apktool b app --aapt $ANDROID_HOME/build-tools/34.0.0/aapt2
Defensive patterns
Strategy: validation
Validate before calling
String v = OS.execAndReturn(new String[]{aaptPath, "version"});
if (v == null || !(v.startsWith("Android Asset Packaging Tool (aapt) 2:")
|| v.startsWith("Android Asset Packaging Tool (aapt) 2."))) {
throw new IllegalArgumentException("Unrecognized aapt version banner: " + v);
} Prevention
- Avoid wrapper scripts as --aapt values; reference real SDK build-tools binaries.
- Pin a known-good build-tools version in CI so banner formats stay stable.
When it happens
Trigger: Pointing --aapt at a shell wrapper or polyfill (e.g. brew shims) whose `version` output has a prefix line; a patched/custom aapt2 with changed banner text; an aapt whose version string uses a different format (e.g. "aapt2 2.19.0" without the long banner).
Common situations: Using third-party aapt2 repackagers (Termux, Nix, brew shims) that alter stdout; wrapper scripts that echo environment info before exec; CI images with instrumented binaries.
Related errors
- Could not execute aapt binary at location:
- Legacy aapt is no longer supported.
- Malicious value for apkFileName: " + mApkFileName
- aapt2 binaries are not available for 32-bit platforms.
- Could not identify platform: " + OSDetection.returnOS()
AI-assisted analysis of iBotPeaches/Apktool@79b63384d7 (2026-08-14).
Data as JSON: /api/errors/a685b6a48ecc505c.
Report an issue: GitHub.