How to install cmake using Android sdkmanager?

You can do this with a simple Script step:

(source: Remove pre-installed CMake by viktorbenei · Pull Request #38 · bitrise-io/android-ndk · GitHub )

#!/bin/bash
set -ex
mkdir -p "${ANDROID_HOME}/licenses"
echo "8933bad161af4178b1185d1a37fbf41ea5269c55" > "${ANDROID_HOME}/licenses/android-sdk-license"
"${ANDROID_HOME}/tools/bin/sdkmanager" --list | grep cmake | tail -n 1 | cut -d \| -f 1 | xargs "${ANDROID_HOME}/tools/bin/sdkmanager"

Note: gradlew can install cmake automatically, you don’t need this script if you build your Android NDK project with gradle(w)!

All you have to do in that case is providing the license (e.g. with:

mkdir -p "${ANDROID_HOME}/licenses"
echo "8933bad161af4178b1185d1a37fbf41ea5269c55" > "${ANDROID_HOME}/licenses/android-sdk-license"

if you use CMake 3.6.3155560, or just copy your own license as described at http://devcenter.bitrise.io/android/frequent-android-issues/#alternative-solution-for-the-license-error) for the android ndk cmake.

Related discussion: [Android-Build NDK] CMake license problem · Issue #33 · bitrise-io/build.issues · GitHub

For anyone having problems with CMake 3.6.4111459, use 24333f8a63b6825ea9c5514f83c2829b004d1fee as the license key instead of 8933...

2 Likes

where do i add this step i recently got error on the android build step it was working up til now

What went wrong:
Could not determine the dependencies of task ‘:react-native-reanimated:mergeReleaseNativeLibs’.
> CMake ‘3.6.0’ was not found in PATH or by cmake.dir property.
** - CMake ‘3.22.1’ found in SDK did not match requested version ‘3.6.0’.**
** - CMake ‘3.25.3’ found in PATH did not match requested version ‘3.6.0’.**

I am also having the same problem @sufyan Where you able to fix it?