Gradle wrapper fails to initialize

In an empty directory, I try to create the wrapper with:

gradle wrapper

Then I just run:

./gradlew --version

And I get the following error:

 % ./gradlew --version                                  [0]

Exception in thread "main"
	at org.gradle.wrapper.Download.downloadInternal(
	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(

I tried with 5.5.0, and I get the same error. Is there something wrong with my system?

Running gradle wrapper will generate the wrapper that will use a distribution of the same version. However, gradle-5.5.1-20190724234647+0000 is not a nightly version built by Gradle, so it can’t be found on the Gradle servers.

It seems likely that you’re using arch, which has built release versions from source, but with them labeled as a nightly snapshot. Therefore, your installed gradle binary from the package manager is broken.

You can solve it for this project by navigating to gradle/wrapper/ and removing the -snapshots and -20190724234647+0000 from the URL. To solve it for all projects going forward until the copy provided is fixed, you could uninstall Gradle from the package manager and manually install the actual release version binary of 5.5.1.

1 Like

I’m not sure it helps, but the Gradle wrapper version, created by the Wrapper task can be set in a wrapper block in the build configuration:

wrapper {
    gradleVersion  '5.5.1'

Though this requires the configuration per project.

1 Like

Got it, thanks!

It seems like I was unlucky because I tried to download 5.5.0 (which was failing), and I did not try 5.5.1 (which does work)…

Should I mark this post as resolved somehow?