2

I use Android Studio 4.0.1 In my project, my local.properties has the following properties:

sdk.dir=C\:\\Users\\xxx\\AppData\\Local\\Android\\Sdk ndk.dir=c\:\\yyy\\tools\\android-ndk-r19c cmake.dir=c\:\\zzz\\cmake-3.17.0-win64-x64 

Despite this, I get a compilation error when I Build -> Rebuild project or Clean project because my CMakeLists.txt begins with cmake_minimum_required(VERSION 3.14.3) and Android Studio uses the CMake included in the Android Studio folder instead of the one I point to in cmake.dir:

CMake Error at CMakeLists.txt:5 (cmake_minimum_required): CMake 3.14.3 or higher is required. You are running version 3.10.2 -- Configuring incomplete, errors occurred! See also "C:/Users/xxx/AndroidStudioProjects/E2e/app/.cxx/cmake/debug/x86/CMakeFiles/CMakeOutput.log". FAILED: build.ninja ninja: error: rebuilding 'build.ninja': subcommand failed C:\Users\xxx\AppData\Local\Android\Sdk\cmake\3.10.2.4988404\bin\cmake.exe -HC:\Users\xxx\AndroidStudioProjects\E2e\app\src\main\cpp -BC:\Users\xxx\AndroidStudioProjects\E2e\app\.cxx\cmake\debug\x86 

What am I missing for AS to pick up the cmake 3.17 I already installed when I select Rebuild Project or Clean Project?

Notes:

  • The directory I point to with cmake.dir is valid and being read by AS. If I introduce a typo in the path, AS complains about it.

  • This problem only occurs when I do Build --> Rebuild project or Clean project. If instead I do Build --> Make project, then AS will pick up the cmake version that I point to in local.properties

2 Answers 2

2

Clean Project worked again after deleting .cxx folder

Sign up to request clarification or add additional context in comments.

1 Comment

It does, but I am still unclear why the correct version of cmake isn't necessarily used.
0

I'm not sure about Android Studio, but you could try editing the project's build.gradle :

android { externalNativeBuild { cmake { path file('CMakeLists.txt') version '3.24.1' } } } 

.... and CMakeLists.txt :

cmake_minimum_required(VERSION 3.24.1) 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.