如何在Android Studio中永久卸载旧版CMake?自动安装问题求助
Hey there! Since you're new to Android Studio, let's walk through fixing this frustrating CMake version problem step by step. The root cause here is Android Studio's automatic dependency management—it keeps reinstalling CMake 3.6 because some part of your project or IDE settings is still asking for it. Here's how to lock it to 3.10:
1. Force CMake 3.10 in Your Project's Build Config
First, tell your project exactly which CMake version to use. This is the most reliable fix:
- Open your app module's
build.gradlefile (it's inside theappfolder, not the root project'sbuild.gradle). - Find the
androidblock, then add or update theexternalNativeBuildsection like this:
android { // ... other existing settings externalNativeBuild { cmake { version "3.10.2" // Use the exact 3.10 version you installed (check SDK Manager for the full number) } } }
Sync your project after saving—this tells Android Studio to prioritize 3.10 over any other version.
2. Set CMake 3.10 as Android Studio's Default
If the project-level config doesn't stop the auto-install, set a global default in the IDE:
- Go to
File > Settings(Windows/Linux) orAndroid Studio > Settings(Mac). - Navigate to
Build, Execution, Deployment > CMake. - In the
CMake executabledropdown, select your installed CMake 3.10 path (it'll look something likecmake-3.10.2/bin/cmake). - Hit
ApplyandOK, then restart Android Studio.
3. Turn Off Auto-Download for Old CMake Versions
Android Studio might be automatically grabbing missing components, including CMake 3.6. Let's disable that:
- Open the SDK Manager (click the SDK icon in the toolbar, or go to
Tools > SDK Manager). - Switch to the
SDK Toolstab. - First, uncheck
Show Package Detailsto see the top-level CMake entry. Then, make sure only your 3.10 version is checked—uncheck CMake 3.6 entirely. - Click
Applyto uninstall 3.6. While you're here, check theSDK Update Sitestab (bottom left) to ensure there's no weird update source forcing old versions.
4. Clean Project Caches to Wipe Old Configs
Sometimes old cached settings stick around, so let's clear them:
- Go to
Build > Clean Project, thenBuild > Rebuild Project. - For extra measure, you can manually delete the
.gradle,.ideafolders in your project root, plus theapp/buildfolder. Then re-open the project and sync again.
After these steps, Android Studio should stop reinstalling CMake 3.6 and use your required 3.10 version for builds. If you still run into issues, double-check your CMakeLists.txt file to make sure it doesn't have a line specifying an older CMake minimum version (like cmake_minimum_required(VERSION 3.6)—you can update that to 3.10 if needed).
内容的提问来源于stack exchange,提问作者Alison

