Android Gradle cannot find the CMake version your module asks for
The Gradle build stops because it cannot find the CMake version named in build.gradle (3.10.2 when none is named)Short answer
Gradle looks for the CMake version your module names, or 3.10.2 when no version is set, and found none. Install that version in SDK Manager under SDK Tools, or change the version in build.gradle to one you have. For a CMake outside the SDK, set cmake.dir in local.properties and keep Ninja on PATH.
Fix it fast
1Find out which cause you have
See what the module asks for and what the SDK has. Look at the version in externalNativeBuild and the folders under the SDK's cmake directory.
grep -n -A3 "externalNativeBuild" app/build.gradle* ls "$ANDROID_HOME/cmake" cat local.properties2Match what you see, then jump to its fix
- 1
The SDK cmake folder is missing, empty, or lacks the version the module asks forCMake is not installed in the SDKFix - 2
The version in the message equals the version in externalNativeBuild, and the SDK has another onebuild.gradle names a CMake version that is not installedFix - 3
The version came from cmake.org or a package manager, not from SDK ManagerYou want a CMake outside the SDK, and Gradle cannot find itFix
- 1
What does the error look like?
The Gradle build stops because it cannot find the CMake version named in build.gradle (3.10.2 when none is named)The native build task fails before any C or C++ file is compiled
Cause 1 of 3
CMake is not installed in the SDK
1Check
A module that sets no CMake version is built with 3.10.2 from the SDK Manager. Also, AGP 4.2 and later can install CMake and the NDK automatically on the first build, but only if their licenses were accepted before.
ls "$ANDROID_HOME/cmake"
"$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" --list_installed | grep -i cmake2Fix
In Android Studio open Tools, SDK Manager, SDK Tools, tick CMake (and NDK Side by side), and apply. On a build machine, accept the licenses first and let the build install it.
yes | "$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" --licenses3Verify
Sync the project and build again.
./gradlew :app:assembleDebugConfirmed by developer.android.com
Cause 2 of 3
build.gradle names a CMake version that is not installed
1Check
The version string in the module's externalNativeBuild block must match an installed CMake exactly.
grep -n "version" app/build.gradle* | grep -i cmake
ls "$ANDROID_HOME/cmake"2Fix
Set the version to one the SDK Manager offers and you have installed, or install the version you named.
android {
externalNativeBuild {
cmake {
version = "3.22.1"
}
}
}3Verify
Sync and build.
./gradlew :app:externalNativeBuildDebugConfirmed by developer.android.com
Cause 3 of 3
You want a CMake outside the SDK, and Gradle cannot find it
1Check
For a CMake that the SDK Manager does not offer, install it from the CMake site, name its version in build.gradle, and then either add it to PATH or set cmake.dir. If cmake.dir is set, Gradle no longer uses PATH. Ninja must also be installed and on PATH.
cmake --version
ninja --version2Fix
Point Gradle at the installation in local.properties, and install Ninja if it is missing.
# local.properties
cmake.dir=/opt/cmake-3.30.03Verify
Build the native code.
./gradlew :app:externalNativeBuildDebugConfirmed by developer.android.com
How do I stop it coming back?
- Name the CMake version in build.gradle so every machine builds with the same one.
- Accept SDK licenses in CI before the first build.
- Keep local.properties out of version control, because cmake.dir is a path on one machine.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Mobile apps
adb cannot start because something already holds its port
adb start-server failed
The adb server must bind local TCP port 5037, and every adb client talks to it there.
2 causes, each with a fixMobile apps
The phone shows as unauthorized and Android Studio will not run the app
adb devices lists the phone but Android Studio cannot deploy to it
An unauthorized phone means it has not trusted this computer's RSA key.
3 causes, each with a fixMobile apps
Android Studio cannot pair the phone over Wi-Fi
The Pair devices over Wi-Fi dialog lists no device
Wireless pairing needs the phone on Android 11 or higher and on the same Wi-Fi network as the computer, with current Platform-Tools.
4 causes, each with a fixMobile apps
adb cannot connect to its daemon or start the server
* daemon started successfully *
The adb server is a background process on your computer that listens on TCP port 5037.
2 causes, each with a fixMobile apps
adb prints 'server version doesn't match this client; killing...'
adb server version doesn't match this client; killing...
adb runs a background server, and every adb command is a client.
3 causes, each with a fixMobile apps
adb tcpip 5555 fails because no device is found
adb: more than one device/emulator
adb tcpip only works while the device is attached and listed by adb, because it tells the phone to start listening on port 5555.
4 causes, each with a fix