Android Studio相當於是Intellij基礎上寫了一個AS插件,這個插件使用gradle作為構建系統,因此構建出現問題先考慮gradle的文檔。
gradle可以使用native build system,例如cmake。gradle中使用cmake時可以指定cmake版本,官方文檔:https://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.CmakeOptions.html
使用情景:我在系統中裝了一個cmake3.13.4,發現android studio的sdk會去自行為ndk工程下載cmake3.6。我只想用cmake3.13.4。
具體設置:
方法1:<項目根目錄>/app/build.gradle:
externalNativeBuild {
cmake {
...
// Specifies the version of CMake the Android plugin should use. You need to
// include the path to the CMake binary of this version to your PATH
// environmental variable.
version "3.13.4"
}
}
方法2:<項目根目錄>/local.properties:
cmake.dir=E\:\\soft\\cmake-3.13.4-win64-x64
總結很傻就是了,只能一個一個項目的配置,不能全局的配置。做AS的大佬們有討論過:https://groups.google.com/forum/#!topic/android-ndk/3WV5iNjISKY ,甩鍋給gradle項目,2333.