6

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

Maximilian Ast
  • 3,369
  • 12
  • 36
  • 47
Bobjoesmith
  • 81
  • 1
  • 1
  • 9

2 Answers2

22

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.

Bjørn Vester
  • 6,851
  • 1
  • 20
  • 20
3

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

  • 1
    Yes, I had to face the same issue and found a 0kb size and tried as explained above. Its worked. – khushbu Aug 04 '22 at 09:31