Gradle wrapper fails with NullPointer Exception


gradlew fails on my TeamCity agent with the following error:

D:\TeamCity\buildAgent2\work\f143a7864defc8db>.\gradlew.bat tasks Downloading https://binaries.domain.local/artifactory/external-libs/gradle/gradle/

Exception in thread “main” java.lang.NullPointerException

at org.gradle.wrapper.Install.listDirs(

at org.gradle.wrapper.Install.access$200(

at org.gradle.wrapper.Install$

at org.gradle.wrapper.Install$

at org.gradle.wrapper.ExclusiveFileAccessManager.access(

at org.gradle.wrapper.Install.createDist(

at org.gradle.wrapper.WrapperExecutor.execute(

at org.gradle.wrapper.GradleWrapperMain.main(

Here’s the






Gradle version is 2.1.

Any ideas what could be causing this? Thanks!

I had a look around the code and it looks like listing files of the directory into which you are trying to install the distribution returns null and the NullPointerExceptions occurs. This might happen when there is a failure in the native JDK code providing the list of files. I can see that you are on Windows. Is it possible that the user running the command doesn’t have rights to list files in the distribution directory?