Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android cannot upgrade CMake version

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 ?

like image 263
michael-martinez Avatar asked Oct 28 '25 01:10

michael-martinez


2 Answers

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'
like image 67
michael-martinez Avatar answered Oct 29 '25 16:10

michael-martinez


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 :)