java.lang.NullPointerException CmakeUtils.getVersionString(CmakeUtils.java:139)

Hi all,

I created a project Android with Native C++ with this guilde https://developer.android.com/studio/projects/add-native-code.html#new-project

But i have a problem with the gradle fail error

* Exception is:
org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':app'.
	at org.gradle.configuration.project.LifecycleProjectEvaluator.wrapException(LifecycleProjectEvaluator.java:84)
	at org.gradle.configuration.project.LifecycleProjectEvaluator.addConfigurationFailure(LifecycleProjectEvaluator.java:77)
	at org.gradle.configuration.project.LifecycleProjectEvaluator.access$400(LifecycleProjectEvaluator.java:55)
	at org.gradle.configuration.project.LifecycleProjectEvaluator$NotifyAfterEvaluate.run(LifecycleProjectEvaluator.java:255)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29)
.......................
Caused by: java.lang.NullPointerException
	at com.android.build.gradle.external.cmake.CmakeUtils.getVersionString(CmakeUtils.java:139)
	at com.android.build.gradle.external.cmake.CmakeUtils.getVersion(CmakeUtils.java:55)
	at com.android.build.gradle.internal.cxx.configure.CmakeLocatorKt.getCmakeRevisionFromExecutable(CmakeLocator.kt:238)
	at 
	....................

Could you have any suggest for fix it ?

Thank you so much

As that is a NullPointerException within the Android Gradle plugin, you should probably better report it to the Android Gradle plugin bug tracker, or search whether an entry already exists and maybe also gives a work-around.

But from a very short look at those source I’d say that it runs cmake --version and does not get any output from that for whatever reason. It should be more robust than to throw an NPE though.

I was receiving this error and I have verified that my environment was getting the wrong cmake executable. Fixing the environment (PATH) to point to the correct cmake fixed this issue for me.

I agree that a fix would make sense because the user has no idea what lead to the NPE from the error. Did someone open a ticket on the CMake plugin?