1. Install NDK and CMake
1. Open the sdk manager
2. Select SDK Tools to install NDK and CMake
If you have version requirements, you can click Show Package Details in the lower right corner to download other versions
Note: You need to download data from Google, so the download may not be successful, configure the magic Internet by yourself
2. Create a Native C++ project
1. Select Native C++ in the lower right corner
2. Fill in the relevant information
3. Select the C++ standard
4. Switch to the project directory from Android
You can see that build.gradle will specify the camke configuration
CMakeLists.txt
5. Other issues
There may be an error [CXX1300] CMake '3.18.1' was not found in SDK, PATH, or by cmake.dir property.
Synchronize first
If you can’t solve it, just add cmake.dir to the local.propetties file and fill in the path of the specified version of cmake.
The problem I personally encountered here should be that there is no synchronization, because the subsequent configuration of cmake.dir can also successfully compile and run the program
3. Reference articles
1. Add C and C++ code to your project
2. Error:CMake '3.10.2' was not found in PATH or by cmake.dir property. CMake '3.10.2' found in SDK did
3.CMake '3.18.1' found in SDK did not match requested version '3.10.2'.