Invalid revision: 3.18.1 CMake in Android Studio
Asked Answered
S

5

29

This is not a question, it is a solution for a technical problem with android studio which I have meet. I will share my doing to fix the error if any one would encounter. The brief error message is: "Invalid revision: 3.18.1-g262b901", while 3.18.1 is latest CMake version in Android studio. But the problem is my project is old and it builds failed with this CMake version. There are 2 solutions, you can choice 1 in 2: -Remove(uninstall) CMake version 3.18.1: Click Android Studio->Preferences->Appearance & Behavior->System Settings->Android SDK->SDK Tool->(enable the Show Package Details checkbox)->CMake->Uncheck 3.18.1 checkbox, then click Apply button in right-bottom conner of dialog. -Set directory path of lower-version CMake in the local.properties file by adding this line to this file: cmake.dir=/Users/admin/Library/Android/sdk/cmake/3.10.2.4988404 (The CMake path can be different in your computer)

Long error message(a small part):

*

at org.gradle.configuration.project.LifecycleProjectEvaluator.addConfigurationFailure(LifecycleProjectEvaluator.java:94)
    at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:89)
Caused by: 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:51)
    at com.android.build.gradle.tasks.ExternalNativeJsonGenerator.createCmakeExternalNativeJsonGenerator(ExternalNativeJsonGenerator.java:688)

Hope it help!

Spanishamerican answered 9/3, 2021 at 4:8 Comment(1)
It's worth nothing that setting cmake.dir option to old version is buggy, and although silences OP's error causes new errors, like my Gradle did later call latest-cmake and ignored cmake.dir option (untill I removed incompatible CMake-versions from Android-SDK's cmake directory).Lajoie
M
37

Downgrading CMake solves this issue (but it's a workaround).

  1. Android Studio > Tools > SDK Manager
  2. Click SDK Tools tab
  3. Check Show Package Details
  4. Expand CMake
  5. Select a lower version
  6. Update local.properties path to the new version

Downgrading CMAKE

enter image description here

Maxson answered 10/3, 2021 at 14:13 Comment(4)
Downgrading shouldn't be a solution , but more of a work around.Selfsustaining
Downgrading is definitely not a long-term solution as sooner or later Google will make it mandatory for us to use cmake 3.18 or things will start failing. I've experienced that with older NDK version. That said my project doesn't build with 3.18, because AS 4.1.3 re-download 3.10 automatically, what a mess :(Revenuer
CMake 3.19.1 works. Presumably newer versions as well.Peacemaker
Another workaround is to replaces questionable cmake that returns pesky 3.18.1-g262b901-dirty version with real cmake.exe from cmake.org that report version just as 3.18.1.Primus
C
4

Gradle version | plugin-version 4.1.2 | 6.5

worked for me

Cora answered 11/3, 2022 at 4:49 Comment(0)
I
2

Upgrade Gradle version and plugin-version to latest works for me

Iolanthe answered 5/7, 2022 at 12:12 Comment(0)
K
1

I upgraded my Gradle version to 4.1.2 and it worked.

Kwan answered 18/10, 2022 at 7:32 Comment(0)
R
0

Defining the following in the local.properties works for me.

ndk.dir=/Users/{USER}/Downloads/sdk/ndk/19.2.5345600
cmake.dir=/Users/{USER}/Downloads/sdk/cmake/3.6.4111459
Rubierubiginous answered 28/3 at 15:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.