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

SePröbläm picture SePröbläm · Apr 22, 2015 · Viewed 169.8k times · Source

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?

Answer

HankCa picture HankCa · Jul 25, 2015

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