How to resolve java.lang.ClassNotFoundException: org.gradle.wrapper.GradleWrapperMain error?
Asked Answered
V

2

8

we are trying to deploy code to a FRC robot with VScode, but we keep getting the error:

Error: Could not find or load main class
org.gradle.wrapper.GradleWrapperMain
Caused by: java.lang.ClassNotFoundException:
org.gradle.wrapper.GradleWrapperMain
The terminal process terminated with exit code: 1

we have found that other people have also gotten similar errors, but none of their solutions have helped us. We would really appreciate any help resolving this error Thanks

Vikiviking answered 11/9, 2019 at 2:21 Comment(0)
D
32

I assume you are using the Gradle wrapper script (gradlew on the command line). This script relies on two other files:

gradle/wrapper/gradle-wrapper.jar
gradle/wrapper/gradle-wrapper.properties

My guess is that the jar file is missing or corrupt. You can try regenerating them by downloading Gradle manually and then running gradle wrapper (note the missing 'w') in the same folder. If this is code you are maintaining in a version control repository (e.g. Git), make sure to add and commit these two files to the repository.

Deepen answered 11/9, 2019 at 21:44 Comment(3)
What's "downloading Gradle manually" ? gradle-wrapper.jar ? or gradle binary ?Temple
You can download a Gradle distribution from gradle.org/releases (or install it through a package manager as explained here: gradle.org/install)Greenling
done. then run "graddle wrapper" in the app folder solved the issue. thanks.Temple
L
5

Was there any recent modifications to the project files? I too faced the same issue after I deleted the entire project unknowingly (shift+delete) and recovered it but somehow the gradlew command wasnt working ( got same error as what you've got). I checked the project folder at below location and was able to see that the gradle-wrapper.jar file was showing 0kb size.

\gradle\wrapper

So i replaced it with correct gradlew jar file and I was able to execute the command without any issues. Might help someone some day! peace :)

EDIT 1: Assuming the above issue is in android studio

Lavoisier answered 18/8, 2020 at 13:46 Comment(1)
Yes, I had to face the same issue and found a 0kb size and tried as explained above. Its worked.Creamer

© 2022 - 2024 — McMap. All rights reserved.