If you changed app --> appModule, you might try to
- close the project from AS
- re-open it with AS
- build > Refresh Linked C++ Project ( this would "force" C++ build side to clean things )
Studio 3.3.0 has a bug affecting IDE behavior, please use version 3.3.1 or better
For Gradle's CMake support, application could use it in 3 ways, starting with most explicit way to "the default":
Vanilla CMake
Assuming Vanilla CMake is downloaded locally from CMake.org, config Gradle with
- inform gradle where cmake directory is, in
local.properties
, like: cmake.dir=/your/vanilla/cmake/dir/like/linux-3.14.0
- pass cmake version to gradle in your
app/build.gradle
file, like
android {
externalNativeBuild {
version "3.14.0-rc2"
path '....' // point to your CMakeLists.txt, relative path to
// THIS app/build.gradle file.
}
}
The down side with Vanilla CMake might be that modules inside SDK ( like AndroidNdkModules.cmake ) may not be in your module path: the project is not using SDK/Studio internally packed CMake.
Explicitly pick up SDK's CMake
As of now, SDK ships 2 cmake builds: 3.6.0-rc2 and 3.10.2. Your sdk manager would download them into the internal known directory (sdk/cmake). Project could pick up a specific one to use. Certainly you could use the above "Vanilla CMake" way, ie., application configures everything -- points cmake.dir to your $SDK's cmake path ( all the way up to, but no including, 'bin/cmake').
You could also ignore the cmake.dir configuration (Studio provides this convenience as it is inside sdk and downloaded by sdk manager), so you only need to configure cmake version in 'app/build.gradle'
android {
externalNativeBuild {
version "3.10.2"
path '....'
}
}
There is no difference between the 2 cmake versions concerning gradle plugin functionality, the difference is inside cmake itself's functionality between the 2 versions.
Use Default: Let the Studio decide cmake version
Currently gradle plugin's default cmake pick is the internal 3.6.0-rc2 version. So if you do not configure 'cmake.dir' AND 'version', the default is in action. You certainly could still configure it as with "Vanilla CMake" way: cmake path and version; it is dreading a little bit, but there is a minor benefit: when Studio/Gradle changes cmake default to 3.10.2 or others, you app is not affected. We do encourage application to use the latest releases. As an application developer, I might also like my app to have a fixed behavior regardless of the versions of building tools; in that sense, explicit way helps.
Additional Notes
- CMake version: you would run 'cmake --version' to get the right version number to configure build.grale, it is NOT the full number embedded inside the sdk's cmake directory.
- your top-level CMakeLists.txt location: indifference to gradle plugin. Practically you might put it together with your C++ code, so when you share with other platforms, they(c++ build script and source code) are inside one directory.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…