Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upgrade CMake version installed with Android-Studio Ubuntu 18.04

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?

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

like image 219
skonz Avatar asked Jul 23 '18 05:07

skonz


3 Answers

From the Official Documentation,

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. Update Android Studio to 3.0 or higher, and update the Android plugin for Gradle to 3.0.0 or higher.

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

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

    android {
       externalNativeBuild {
           cmake {
               version "3.7.1"
           }
       }
    }
    
  4. 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.

Hope it helps!

like image 73
Prokash Sarkar Avatar answered Oct 21 '22 06:10

Prokash Sarkar


Also from the documentation:

While not a best practice, you may specify the CMake version as the minimum version by adding a + to the end of the build.gradle entry, such as 3.10.2+.

This will enable the "or higher" part of your question.

like image 21
jpihl Avatar answered Oct 21 '22 08:10

jpihl


Preference -> System Settings -> Android SDK then choose SDK Tools tab

Under that tab find Cmake section check the box which has higher version and uncheck the rest. then apply and re-sync project.

like image 2
wdanxna Avatar answered Oct 21 '22 08:10

wdanxna