michael-martinez
michael-martinez

Reputation: 797

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 ?

Upvotes: 4

Views: 4419

Answers (3)

user15521563
user15521563

Reputation:

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

Upvotes: 1

AutoUpdatingBSoD
AutoUpdatingBSoD

Reputation: 1

I had a similar problem (yet not related to the NDK so I gave your solution a shot). I just want to preface that your answer helped me realize something that was horribly wrong with my installation of Android Studio in terms of configuration.

Uninstalling and Reinstalling the IDE helped me find the true culprit as to why Android Studio just wouldn't compile: Inadequate SFML configuration for Android in my case. I don't have enough reputation points as this is a new account, or I'd upvote your answer for helping me realize what I did wrong.

Thank you!

Upvotes: 0

michael-martinez
michael-martinez

Reputation: 797

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'

Upvotes: 4

Related Questions