Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Android Studio 3 use cmake 3.6.0 as default?

My Android studio is version 3.3.2 and i trying to link gradle to my native library, my module's build.gradle is:

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')
        }
    }
}

If i don't specify the cmake version to '3.10.2', I am getting the following error:

CMake '3.6.0' was not found in PATH or by cmake.dir property. - CMake '3.10.2' found in SDK did not match requested version '3.6.0'. - CMake '3.12.1' found in PATH did not match requested version '3.6.0'. Install CMake 3.6.0

So I'am confused why is so! Why does it ask for the version of cmake itself to be 3.6.0.

Kindly review and give feedback.

like image 296
FarmerLi Avatar asked Mar 14 '19 06:03

FarmerLi


People also ask

What is use of CMake in Android Studio?

CMake: an external build tool that works alongside Gradle to build your native library. You do not need this component if you only plan to use ndk-build. LLDB: the debugger Android Studio uses to debug native code. By default, LLDB will be installed alongside Android Studio.

Where is android toolchain CMake?

The CMake toolchain file The toolchain file used for the NDK is located in the NDK at <NDK>/build/cmake/android.

Where is android NDK installed?

Android Studio installs all versions of the NDK in the android-sdk /ndk/ directory. Each version is located in a subdirectory with the version number as its name. Note: Remove this property before distributing your source code; it should be left outside of your version control system.

How do I know what version of android NDK I have?

Go to Tools->SDK Manager (or Files->Settings->Appearance & Behavior->System Settings->Android SDK ). Then select the SDK Tools tab, and check the Show Package Details checkbox. You will see your NDK version.


1 Answers

Try to add the configuration below to your gradle:

   externalNativeBuild {
        cmake {
            version "3.10.2" // here
        }
    }
like image 82
Jeff Wong Avatar answered Sep 18 '22 08:09

Jeff Wong