美文网首页
Cocos2dx下载Gradle出错

Cocos2dx下载Gradle出错

作者: 一剑卿心 | 来源:发表于2018-03-29 22:10 被阅读25次

Cocos2dx3.8在windows平台使用cocos compile指令编译android版本时,遇到报错:

cocos compile -p android --android-studio

Error:
Downloading https://services.gradle.org/distributions/gradle-2.4-all.zip
Exception in thread "main" java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:649)
at sun.security.ssl.BaseSSLSocketImpl.connect(BaseSSLSocketImpl.java:173)
at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:432)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:527)
at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:275)
at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:371)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1103)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:997)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1511)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1439)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
at org.gradle.wrapper.Download.downloadInternal(Download.java:58)
at org.gradle.wrapper.Download.download(Download.java:44)
at org.gradle.wrapper.Install$1.call(Install.java:59)
at org.gradle.wrapper.Install$1.call(Install.java:46)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)
at org.gradle.wrapper.Install.createDist(Install.java:46)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:126)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)

解决方法:

  1. 直接用浏览器下载gradle-2.4-all.zip到本地。假设下载到D:/gradle-2.4-all.zip。
  2. 找到项目中的gradle-wrapper.properties文件。
  3. 将其中的url路径distributionUrl=https://services.gradle.org/distributions/gradle-2.4-all.zip改为本地路径。
distributionUrl=file\:/D:/gradle-2.4-all.zip

参考:
http://blog.hissummer.com/2016/10/gradle-wrapper-%E4%B8%8B%E8%BD%BDgradle%E9%80%9F%E5%BA%A6%E8%B6%85%E7%BA%A7%E6%85%A2%E5%A6%82%E4%BD%95%E8%A7%A3%E5%86%B3%EF%BC%9F/

https://github.com/facebook/react-native/issues/2726

相关文章

网友评论

      本文标题:Cocos2dx下载Gradle出错

      本文链接:https://www.haomeiwen.com/subject/mqwvcftx.html