随Android-Studio Ubuntu 18.04安装的升级CMake版本 [英] Upgrade CMake version installed with Android-Studio Ubuntu 18.04

查看:531
本文介绍了随Android-Studio Ubuntu 18.04安装的升级CMake版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近在Ubuntu 18.04上安装了Android Studio,以便为Android进行一些本机C ++开发.在编译需要cmake 3.9或更高版本的项目(由于cmake依赖关系)时,我发现Android Studio安装的cmake版本仅为3.6版本.是否有一种干净的方法可以通过SDK Manager升级与Android Studio一起安装的cmake版本?

I recently installed Android Studio on Ubuntu 18.04 to do some native C++ development for Android. While compiling a project that required cmake 3.9 or higher (due to cmake dependencies) I found that the cmake version installed by Android Studio was only version 3.6. Is there a clean way to upgrade the cmake version installed with Android Studio via the SDK Manager?

我正在运行Android Studio版本3.1.3,并且已从SDK Manager-> SDK工具安装了cmake.

I'm running Android Studio version 3.1.3 and Installed cmake from SDK Manager -> SDK tools.

推荐答案

从官方 SDK Manager包括CMake的分支版本,最高版本为 3.6.4 .如果要使用 3.7或更高版本的CMake ,请按以下步骤操作:

The SDK Manager includes forked versions of CMake up to version 3.6.4. If you want to use CMake version 3.7 or higher, proceed as follows:

  1. 将Android Studio更新到3.0或更高版本,并将Gradle的Android插件更新到3.0.0或更高版本.

  1. Update Android Studio to 3.0 or higher, and update the Android plugin for Gradle to 3.0.0 or higher.

从CMake官方网站下载并安装 CMake 3.7或更高版本.

Download and install CMake 3.7 or higher from the official CMake website.

在模块的build.gradle文件中指定要让Gradle使用的CMake版本:

Specify the CMake version you want Gradle to use in your module's build.gradle file:

android { externalNativeBuild { cmake { version "3.7.1" } } }

android { externalNativeBuild { cmake { version "3.7.1" } } }

将CMake安装的路径添加到PATH环境变量中,或将其包含在项目的local.properties文件中,作为cmake.dir="path-to-cmake".如果Gradle无法找到您在build.gradle文件中指定的CMake版本,则会出现生成错误.如果设置此属性,则Gradle将不再使用PATH查找CMake.

Either add the path to the CMake installation to your PATH environment variable or include it in your project's local.properties file, as cmake.dir="path-to-cmake". If Gradle is unable to find the version of CMake you specified in your build.gradle file, you get a build error. If you set this property, Gradle no longer uses PATH to find CMake.

希望有帮助!

这篇关于随Android-Studio Ubuntu 18.04安装的升级CMake版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆