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

**URL:** <https://discuss.gradle.org/t/java-lang-nullpointerexception-cmakeutils-getversionstring-cmakeutils-java-139/44593>\
**Category:** Help/Discuss\
**Created:** [January 3, 2023, 10:54am UTC](https://discuss.gradle.org/t/java-lang-nullpointerexception-cmakeutils-getversionstring-cmakeutils-java-139/44593 "2023-01-03T10:54:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hanhphuclahappy](https://avatars.discourse-cdn.com/v4/letter/h/a6a055/32.png) [@hanhphuclahappy](https://discuss.gradle.org/u/hanhphuclahappy)\
**Post date:** [January 3, 2023, 10:54am UTC](https://discuss.gradle.org/t/java-lang-nullpointerexception-cmakeutils-getversionstring-cmakeutils-java-139/44593/1 "2023-01-03T10:54:14Z")

</div>

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](https://developer.android.com/studio/projects/add-native-code.html#new-project)

But i have a problem with the gradle fail error

```plaintext
* 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

 ![Screenshot from 2023-01-03 17-47-42](https://global.discourse-cdn.com/gradle/original/2X/1/1634f1f02df981c49f1934cae5cba78ca5c1ae71.png)

---

<div class="post-metadata">

**Author:** ![Vampire](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vampire/32/9082_2.png) [@Vampire](https://discuss.gradle.org/u/Vampire)\
**Post date:** [January 12, 2023, 7:57pm UTC](https://discuss.gradle.org/t/java-lang-nullpointerexception-cmakeutils-getversionstring-cmakeutils-java-139/44593/2 "2023-01-12T19:57:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![nik](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/nik/32/9149_2.png) [@nik](https://discuss.gradle.org/u/nik)\
**Post date:** [July 27, 2023, 8:30pm UTC](https://discuss.gradle.org/t/java-lang-nullpointerexception-cmakeutils-getversionstring-cmakeutils-java-139/44593/3 "2023-07-27T20:30:31Z")

</div>

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?
