Maaz Zindani

Loading the index…

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

Android Gradle stops with CXX1405 or CXX1429 while configuring CMake

Your error

[CXX1429] error when building with cmake using /path/to/app/src/main/cpp/CMakeLists.txt2 more lines it can show

Fix it fast

Most common cause, 1 of 3

CMakeLists.txt lists a source file under a wrong or outdated path

Correct the path so it starts from the folder of CMakeLists.txt, or move the file back.

Fix
# app/src/main/cpp/CMakeLists.txt
add_library(native-lib SHARED
            native-lib.cpp)      # the file sits next to CMakeLists.txt
Did this fix it?
Full steps for this cause: check, fix, verify

Short answer

[CXX1405] and [CXX1429] error when building with cmake mean the CMake configure run started by the Android Gradle plugin exited with an error. The code is a wrapper: the real cause is the CMake Error printed further down. AGP 7.0 to 7.3 say CXX1405, AGP 7.4 to 9.5 say CXX1429. Fix that CMake line, then rebuild.

  • Applies to Android Gradle plugin 7.4 to 9.5.2 (CXX1429 wording), AGP 7.0 to 7.3 (CXX1405 wording), Android Studio Rabbit 2 2026.2.2, CMake installed through the SDK Manager
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Which cause do you have?

The CXX line itself never says what broke. AGP saves the output of the failed configure run in text files inside the module, so print the error output and look for the first line that starts with CMake Error. Replace app with the module folder named in the CMakeLists.txt path of the error (for a React Native library that folder sits under node_modules).

Run this first
find app -name "configure_stderr*.txt" -exec tail -n 40 {} +

Then find the line you see in this list and open its fix:

  1. 1CMakeLists.txt lists a source file under a wrong or outdated pathCMake Error at CMakeLists.txt:<line> (add_library): Cannot find source file:
  2. 2find_package() asks for a library from an AAR, but Prefab is offCould not find a package configuration file provided by "<package>" with any of the following names:
  3. 3cmake_minimum_required() wants a newer CMake than the one Gradle ranCMake 3.xx or higher is required. You are running version 3.yy

What does the error look like?

  • [CXX1429] error when building with cmake using /path/to/app/src/main/cpp/CMakeLists.txt
  • [CXX1405] error when building with cmake using /path/to/app/src/main/cpp/CMakeLists.txt
  • C++ build system [configure] failed while executing:

Cause 1 of 3

CMakeLists.txt lists a source file under a wrong or outdated path

You seeCMake Error at CMakeLists.txt:<line> (add_library): Cannot find source file:

Check

When CXX1429 or CXX1405 comes with Cannot find source file, CMake could not open a source listed in add_library() or add_executable(). Paths in the script are read relative to the folder that holds CMakeLists.txt, not relative to the module or the project root, so a file moved during a refactor or a path copied from another project breaks the configure run.

Check
grep -n "add_library\|add_executable" app/src/main/cpp/CMakeLists.txt
ls app/src/main/cpp/

Fix

Correct the path so it starts from the folder of CMakeLists.txt, or move the file back. After renaming or removing a library, run Build > Clean Project so the old output is dropped.

Fix
# app/src/main/cpp/CMakeLists.txt
add_library(native-lib SHARED
            native-lib.cpp)      # the file sits next to CMakeLists.txt

Verify

Build the module again. The configure step passes and the error file no longer holds a CMake Error line.

Verify
./gradlew :app:assembleDebug
find app -name "configure_stderr*.txt" -exec grep -l "CMake Error" {} +

Confirmed by developer.android.com

Did this fix it?

Cause 2 of 3

find_package() asks for a library from an AAR, but Prefab is off

You seeCould not find a package configuration file provided by "<package>" with any of the following names:

Check

This CXX1429 variant means CMake searched for a config-file package that nobody provided. Gradle hands native libraries from AAR dependencies to CMake as Prefab packages, and only for modules where the prefab build feature is switched on; without it a line like find_package(curl REQUIRED CONFIG) fails during configure.

Check
grep -n "find_package" app/src/main/cpp/CMakeLists.txt
grep -n "prefab" app/build.gradle*

Fix

Turn on Prefab in the android block of the module, keep the AAR in dependencies, and link the target the package exports. The package and module names come from the library's own documentation.

Fix
// app/build.gradle.kts
android {
    buildFeatures {
        prefab = true
    }
}

# CMakeLists.txt
find_package(curl REQUIRED CONFIG)
target_link_libraries(app curl::curl)

Verify

Sync and build. find_package() resolves and the linked library ends up in the APK.

Verify
./gradlew :app:assembleDebug

Confirmed by developer.android.com

Did this fix it?

Cause 3 of 3

cmake_minimum_required() wants a newer CMake than the one Gradle ran

You seeCMake 3.xx or higher is required. You are running version 3.yy

Check

If the configure output says a higher CMake is required, the script's cmake_minimum_required() line is newer than the CMake binary Gradle picked. Gradle uses the version named in externalNativeBuild, and the command printed under failed while executing shows which cmake binary actually ran.

Check
grep -n "cmake_minimum_required" app/src/main/cpp/CMakeLists.txt
grep -n -A4 "externalNativeBuild" app/build.gradle*
sdkmanager --list | grep -i cmake

Fix

Install a CMake package at least as new as the script asks for, and name that exact version in the module so every machine and CI runner uses it.

Fix
sdkmanager --install "cmake;<version from the list>"

// app/build.gradle.kts
android {
    externalNativeBuild {
        cmake {
            version = "<same version>"
        }
    }
}

Verify

Build again and check that the configure output no longer reports a version requirement.

Verify
./gradlew :app:assembleDebug

Confirmed by developer.android.com

Did this fix it?

How do I stop it coming back?

  • Pin both ndkVersion and externalNativeBuild.cmake.version in the module, so a new laptop or runner cannot pick a different toolchain.
  • Keep cmake_minimum_required() at or below the CMake version you pin, and raise both in one commit.
  • Run a CI job that builds a variant with native code on every pull request touching CMakeLists.txt or cpp files.
  • When a native build fails, read configure_stderr first instead of clearing caches.

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 on the same stack: QistLock, Nuclear Home Video.

Next step

Want this handled for good?

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