Build in CI is getting failed with gradle download

i was using gradle-8.1.1, but build was getting failed with below error. someone please help on this… i tried changing to different versions, still no luck. deleted gradlew and its properties and regenerated… still same error.

Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain

Caused by: java.lang.ClassNotFoundException: org.gradle.wrapper.GradleWrapperMain

Do you maybe miss the Gradle wrapper jar file?

nope, have the gradlew/wrapper file on root project.

PFB:

– Found gradle start

– Found Gradle Build

DEV environment

Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain

Caused by: java.lang.ClassNotFoundException: org.gradle.wrapper.GradleWrapperMain

The Gradle wrapper consists of four files. I asked whether you have the jar file of the four, because that missing is the typical cause for that error.

gradlew, gradle-wrapper.jar, gradle-wrapper.properties, gradlew.bat

these 4 right?

have not changed anything related to gradle files, till last friday it was working fine… build was success… from monday onwards, this error occurs… build is getting failed with this error.

i tried downgrade/upgrade the gradle versions for testing, but no luck

please tell where am i wrong.

docker image used : alvrme/alpine-android:android-33-jdk17

https://hub.docker.com/layers/alvrme/alpine-android/android-33-jdk17/images/sha256-73b44bd575884174bb0329c8049e6563c39c414880c35cd897ea46e151a753e7?context=explore

Yes, those four.
Well something must have changed obviously. :slight_smile:
Maybe modify the gradlew script so that it outputs the commandline executed to see whether there is something fishy.

Well, maybe I should stop using LLMs, because I’ve just run into a similar issue. :slight_smile: Copilot generated a project for me with the following .gitignore content:

*.jar
*.war
*.ear

By the way, most related StackOverflow answers also point out a .gitignore problem.

Because most typically that is the problem. :slight_smile:
Though not in this thread I’d say as it worked and suddenly stopped working.
Even if the .gitignore of OP contained *.jar that should not be a problem as the gradle-wrapper.jar file was already versioned and once a path is versioned, the .gitignore is ignored anyway for that path.

But yeah, a “bad” .gitignore can easily cause the same error as then the JAR is missing as suspected above unless you force-add it to the Git repository. :slight_smile:

1 Like