为什么 Android Studio 3 默认使用 cmake 3.6.0?

Far*_*rLi 10 android cmake gradle

我的 Android 工作室是 3.3.2 版,我试图将 gradle 链接到我的本机库,我的模块的 build.gradle 是:

android {
    compileSdkVersion 28

    defaultConfig {
        minSdkVersion 18
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        ndk {
            moduleName "MyModule"
            abiFilters 'x86', 'armeabi-v7a'
        }
    }

    externalNativeBuild {
        cmake {
            version "3.10.2"  // The key line
            path file('CMakeLists.txt')
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

如果我没有将 cmake 版本指定为“3.10.2”,则会出现以下错误:

在 PATH 或 cmake.dir 属性中找不到 CMake '3.6.0'。- 在 SDK 中找到的 CMake '3.10.2' 与请求的版本 '3.6.0' 不匹配。- 在 PATH 中找到的 CMake '3.12.1' 与请求的版本 '3.6.0' 不匹配。安装 CMake 3.6.0

所以我很困惑为什么会这样!为什么它要求cmake本身的版本是3.6.0。

请查看并提供反馈。

Jef*_*ong 9

尝试将以下配置添加到您的 gradle 中:

   externalNativeBuild {
        cmake {
            version "3.10.2" // here
        }
    }
Run Code Online (Sandbox Code Playgroud)

  • 我还必须将其添加到 local.properties: `cmake.dir=<path to...>/Android/Sdk/cmake/3.10.2.4988404` (2认同)
  • @SIVAKUMAR.J 在名为“local.properties”的文件中设置行“cmake.dir=<path to...>/Android/Sdk/cmake/3.10.2.4988404” (2认同)