简体   繁体   中英

Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain and no gradle-wrapper.jar exists

I use Android Studio 4.1.1 to build an Android app which works nicely. When I try to run the gradlew script from terminal I get an error:

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

Which means that gradle wrapper cannot find the gradle-wrapper.jar. All solutions [1] [2] say I should check the.gitignore and add the gradle-wrapper.jar, but since my computer is the main computer where I created the project there is no issue with missing files in git. However, I simply don't have a gradle-wrapper.jar anywhere in the project folder. Nor a gradle binary. So I cannot rebuild the gradle-wrapper.jar what was recommended in other postings here . I have a gradle-wrapper.properties thou. Building from Android Studio works fine, so there is no issue with gradle itself.

Any ideas how I can restore the gradle wrapper?

Ok, I found a "solution". I just searched for a gradle-wrapper.jar on github and put it into the gradle folder of my project. Now it works. But if anyone has a proper solution I'm happy to know, so I won't accept my answer as the right answer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM