apache/cordova-android · error · RuntimeException
No installed build tools found. Please install the Android b
Error message
No installed build tools found. Please install the Android build tools version ${minBuildToolsVersionString}. What it means
doFindLatestInstalledBuildTools runs during gradle configuration when no explicit build-tools version is set. It resolves the SDK via getAndroidSdkDir(), lists $SDK/build-tools, parses each entry as a version, and keeps only those in the same major series as MIN_BUILD_TOOLS_VERSION (higher than 0.0.0 and lower than (major+1).0.0). If nothing survives — the directory is empty, missing, or holds only entries of a different major series — it throws this RuntimeException. A failure to locate the SDK itself also surfaces here, rethrown after the 'An exception occurred while trying to find the Android build tools.' println.
Source
Thrown at framework/cordova.gradle:71
try {
def buildToolsDir = new File(getAndroidSdkDir(), "build-tools")
buildToolsDirContents = buildToolsDir.list()
} catch (e) {
println "An exception occurred while trying to find the Android build tools."
throw e
}
def minBuildToolsVersion = new Version(minBuildToolsVersionString)
def maxVersion = new Version((minBuildToolsVersion.getMajor() + 1) + ".0.0")
def highestBuildToolsVersion = buildToolsDirContents
.collect { new Version(it) }
// Invalid inputs will be handled as 0.0.0
.findAll { it.isHigherThan('0.0.0') && it.isLowerThan(maxVersion) }
.max()
if (highestBuildToolsVersion == null) {
throw new RuntimeException("""
No installed build tools found. Please install the Android build tools
version ${minBuildToolsVersionString}.
""".replaceAll(/\s+/, ' ').trim())
}
if (highestBuildToolsVersion.isLowerThan(minBuildToolsVersionString)) {
throw new RuntimeException("""
No usable Android build tools found. Highest ${minBuildToolsVersion.getMajor()}.x installed version is
${highestBuildToolsVersion.getOriginalString()}; Recommended version
is ${minBuildToolsVersionString}.
""".replaceAll(/\s+/, ' ').trim())
}
highestBuildToolsVersion.getOriginalString()
}
String getAndroidSdkDir() {
def rootDir = project.rootDirView on GitHub (pinned to 7c1e190064)
Solutions
- Install the recommended build-tools package: sdkmanager 'build-tools;<version from the message>' (or Android Studio → SDK Manager → SDK Tools → Android SDK Build-Tools).
- Verify which SDK path is actually used: echo $ANDROID_HOME $ANDROID_SDK_ROOT and cat platforms/android/local.properties — fix sdk.dir / env vars if they point at the wrong folder.
- Confirm the install landed where the build looks: ls "$ANDROID_HOME/build-tools" must show a directory in the same major series as the message's version.
- Alternatively pin an already-installed acceptable version for this build: ./gradlew -PcdvBuildToolsVersion=<installed> (it must still be >= the platform minimum or the later min-version check fires).
Example fix
# before $ ls "$ANDROID_HOME/build-tools" 34.0.0 # minimum is 35.x — nothing usable in that series # after $ sdkmanager 'build-tools;35.0.0' $ ls "$ANDROID_HOME/build-tools" 34.0.0 35.0.0
Defensive patterns
Strategy: validation
Validate before calling
# Pre-flight before cordova build / gradlew
: "${ANDROID_HOME:?export ANDROID_HOME (or set sdk.dir in platforms/android/local.properties)}"
MAJOR=$(grep -oP '(?<=MIN_BUILD_TOOLS_VERSION": ")\d+' platforms/android/CordovaLib/cdv-gradle-config-defaults.json)
ls "$ANDROID_HOME/build-tools" 2>/dev/null | grep -q "^$MAJOR\." \
|| { echo "No $MAJOR.x build-tools in $ANDROID_HOME — run: sdkmanager 'build-tools;<min-version>'"; exit 1; } Prevention
- Bake the required build-tools package into CI images at image-build time, not job time.
- Export both ANDROID_HOME and ANDROID_SDK_ROOT in every build environment.
- Pin -PcdvBuildToolsVersion to the exact installed version in CI to bypass discovery entirely.
When it happens
Trigger: ANDROID_HOME / ANDROID_SDK_ROOT / local.properties sdk.dir points at a folder without a build-tools subdirectory (wrong path, a JDK, or an empty SDK); the build-tools package was never installed on the machine; only a different major series is installed (e.g. solely 34.x while the platform minimum is 35.x, so discovery excludes it).
Common situations: Fresh CI docker images that ship platform-tools but no build-tools; ANDROID_HOME pointing to ~/android-sdk when the SDK actually lives in ~/Android/Sdk (case-sensitive path on Linux); CLI-only workflows where Android Studio never got the chance to auto-install build-tools on demand.
Related errors
- Unable to determine Android SDK directory.
- No usable Android build tools found. Highest ${minBuildTools
- Expected Android Build Tools version >= ${cordovaConfig.MIN_
- Malformed BoM platform: ${p}
- Unsupported system library (does not work with gradle): ${p}
AI-assisted analysis of apache/cordova-android@7c1e190064 (2026-08-22).
Data as JSON: /api/errors/5aba76e8a206d747.
Report an issue: GitHub.