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?
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.
Open gradle-wrapper. properties(go to Gradle > wrapper > gradle-wrapper. properties and manually change the distributionUrl property in the file.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With