2017-04-15 97 views
2

我是新來的搖籃,並試圖在我的Windows操作系統的PC安裝搖籃,我下面提到的錯誤錯誤:無法找到或加載主類org.gradle.launcher.GradleMain

Error: Could not find or load main class org.gradle.launcher.GradleMain 

只有我做的事情是,我跟着網站的gradle給出Gradle installation的gradle的安裝步驟,並在命令提示符下鍵入

gradle -v 

和我上面提到的例外。關於發生了什麼以及如何解決它的任何線索。

這是我做了什麼:

  1. Downloaded the zip file
  2. Copied 'gradle-3.5' from the zip file to a folder I created in C drive (C:\Gradle)
  3. Set GRADLE_HOME to 'C:\Gradle\gradle-3.5'
  4. Set Path to '%GRADLE_HOME%\bin'
  5. Opened cmd and typed gradle -v and got this error

回答

3

基本上這意味着搖籃找不到你gradle/wrapper/gradle-wrapper.jar

你必須遵循步驟3和設置環境變量:

Microsoft Windows users

In File Explorer right-click on the This PC (or Computer) icon, then click Properties -> Advanced System Settings -> Environmental Variables.

Under System Variables select Path, then click Edit. Add an entry for C:\Gradle\gradle-3.5\bin. Click OK to save.

來源:https://gradle.org/install#configure

最簡單的方法,就是在你的項目中只使用gradlew.bat,它會自動下載Gradle爲您!

+2

是的。大多數情況下遇到這個錯誤只是錯過了'gradle/wrapper/gradle-wrapper.jar'文件。 –

+0

@Max Peng:在使用gradlew時得到相同的錯誤,是的。 –

相關問題