I need to use CMake version at least 3.15 in my Android Studio project. The installed version was lower so I went to the package manager and installed version 3.18.1 and synced the project (following https://developer.android.com/studio/projects/install-ndk#vanilla_cmake).
But after syncing I am getting the error:
java.lang.NumberFormatException: Invalid revision: 3.18.1-g262b901
at com.android.repository.Revision.parseRevision(Revision.java:133)
at com.android.repository.Revision.parseRevision(Revision.java:155)
at com.android.build.gradle.external.cmake.CmakeUtils.getVersion(CmakeUtils.java:56)
at com.android.build.gradle.external.cmake.server.ServerFactory.create(ServerFactory.java:42)
at com.android.build.gradle.tasks.CmakeServerExternalNativeJsonGenerator.executeProcessAndGetOutput
I tried reopening Android Studio, upgrading my NDK version to 22.1 but I get the same error. I am using lattest Android Studio version 4.2.1.
What prevents a specific CMake version from being used ? Gradle version ? NDK version ? Android Studio version ?
Solved it finally by displaying more logs on the error message. The key action is to update Gradle in my project level build.gradle file,
I changed:
classpath 'com.android.tools.build:gradle:4.0.2'
To:
classpath 'com.android.tools.build:gradle:4.2.1'
first go to your pc dir wich android sdk is installed
in my pc dir is ->  C:\Users\lotka-pc\AppData\Local\Android\Sdk\cmake
and delete the older version
second in your gradle file module you should change the version of cmake
    externalNativeBuild {
    cmake {
        path file('src/main/cpp/CMakeLists.txt')
        version '3.18.1'
    }
}
third - you should check dir
src/main/cpp/CmakeList.txt 
and check the version
cmake_minimum_required(VERSION 3.10.2)
these will work :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With