Saturday, 4 August 2018

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

Sometime you may face error "Could not find or load main class org.gradle.wrapper.GradleWrapperMain" while working with Gradle project which is very difficult to find out the root cause of the issue. In this article, we'll explain the root cause of the issue and how to resolve this.

Issue Description

Could not find or load main class org.gradle.wrapper.GradleWrapperMain. Bitbucket pipeline or Jenkins console output, the build is failed – “Could not find org.gradle.wrapper.GradleWrapperMain”

The symptom of the issue

This error will be thrown when we are trying to clean or build the Gradle project and gradlew build unable to find the gradle folder which contains the gradle-wrapper.jar file. This might be possible developer has missed out to check-in the Gradle folder in the repository.

Solution

If wrapper folder doesn't exist under gradle folder then create the wrapper folder and paste gradle-wrapper.jar & grade-wrapper.properties in the wrapper folder.

Project structure should be as below

---Project Folder
                ---gradle
                                --wrapper
                                                --gradle-wrapper.jar
                                                --gradle-wrapper.properties
                --gradlew
                --graldew.bat    

Post this, try to build the project again and you will notice that the error is no more.

No comments:

Post a Comment