Pradeep Simba
Pradeep Simba

Reputation: 322

could not get version from cmake.dir

when I build syc my android project it comes like this enter image description here

enter image description here

local.properties

enter image description here

How can I solve this error?

Upvotes: 3

Views: 7404

Answers (3)

Ravi
Ravi

Reputation: 827

It was frustrating to find this silly mistake so documenting here for future visitors.

create file local.properties under your android folder if not already there with following key=value pair

cmake.dir=<path_to_cmake_folder_without_quote_and_without_bin>

e.g. cmake.dir=/use/local/cmake

Note that following won't work

cmake.dir="/use/local/cmake"

cmake.dir=/use/local/cmake/bin

Upvotes: 1

LUser
LUser

Reputation: 1194

For me, I am using the newest version of CMAKE from the source repo. It by default installs to /usr/local/bin/cmake.

The problem is that the error message never says that it is adding /bin/cmake to the path...

so for the future in your local.properties make like so:

cmake.dir=/usr/local/

Upvotes: 2

xaviersjs
xaviersjs

Reputation: 1737

You may want to specify the cmake version in your build.gradle file thusly [1]

android {
    ...
    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.10.2.4988404"
        }
    }
}

For versions downloaded by the sdk manager, I didn't need to specify cmake.dir in my local.properties. Try deleting it entirely.

I needed to specify cmake.dir when I used a version of cmake that wasn't installed from Android Studio's sdk manager. Then I had to put the path to the cmake installation directory (the one containing the bin/cmake), not the cmake binary directory directly.

[1] Snippet is copied from https://developer.android.com/reference/tools/gradle-api/4.1/com/android/build/api/dsl/Cmake#version

Upvotes: 5

Related Questions