Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I cleaned the whole project by deleting local directories like ~/.gradle, ~/.m2 ~./android and ~/workspace/project/.gradle and chosing File -> Invalidate Caches / Restart... in Android Studio. Now execution of the command ./gradlew leads to the following output:

usr$ ./gradlew tasks
Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain

Needless to say, I deleted too much, the question is how can it be repaired again? Do you have any ideas how to fix this?

like image 427
SePröbläm Avatar asked Oct 04 '22 21:10

SePröbläm


People also ask

How do you set up Gradle wrappers?

To initially setup the wrapper, you will need to have Gradle installed on your machine first. Download it from the Gradle website, not forgetting to add the bin directory to your PATH environment variable. In an empty directory run gradle init to start the Gradle project setup wizard.

How do you open Gradle wrapper properties?

Open gradle-wrapper. properties(go to Gradle > wrapper > gradle-wrapper. properties and manually change the distributionUrl property in the file.

What does Gradlew clean do?

To clean cache in react native, open terminal, go to your project android folder, and run gradlew clean command it will clear react native cache.


1 Answers

In addition to @RaGe's answer may be the situation I faced where i had a global git ignore that was ignoring .jar files and so the gradle wrapper jar was never being committed. Thus I was getting that error on the Jenkins server after an attempted /var/lib/jenkins/my_project/gradlew build. I had to explicitly force an add of the jar and then commit:

git add -f gradle/wrapper/gradle-wrapper.jar
like image 273
HankCa Avatar answered Oct 19 '22 04:10

HankCa