Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

Android Gradle cannot find the CMake version your module asks for

ErrorThe 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.

  • Applies to AGP 8.x, Android Studio, CMake 3.22, NDK r27
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 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.properties
  2. 2Match what you see, then jump to its fix

    1. 1The SDK cmake folder is missing, empty, or lacks the version the module asks forCMake is not installed in the SDKFix
    2. 2The 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. 3The version came from cmake.org or a package manager, not from SDK ManagerYou want a CMake outside the SDK, and Gradle cannot find itFix

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 cmake

2Fix

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" --licenses

3Verify

Sync the project and build again.

./gradlew :app:assembleDebug

Confirmed by developer.android.com

Did this fix it?

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:externalNativeBuildDebug

Confirmed by developer.android.com

Did this fix it?

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 --version

2Fix

Point Gradle at the installation in local.properties, and install Ninja if it is missing.

# local.properties
cmake.dir=/opt/cmake-3.30.0

3Verify

Build the native code.

./gradlew :app:externalNativeBuildDebug

Confirmed by developer.android.com

Did this fix it?

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

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 fix

Mobile 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

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.