2

我正在关注这个 grpc 教程,但我什至无法完成第一步。第一步是 git clone 项目然后运行

cd examples
./gradlew installDist

我被这个堆栈跟踪击中

Downloading https://services.gradle.org/distributions/gradle-2.13-bin.zip

Exception in thread "main" java.net.UnknownHostException: services.gradle.org
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:589)
    at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:668)
    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:264)
    at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:367)
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1105)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:999)
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1513)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1441)
    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:61)
    at org.gradle.wrapper.Install$1.call(Install.java:48)
    at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)
    at org.gradle.wrapper.Install.createDist(Install.java:48)
    at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:128)
    at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)

我认为这是一个代理问题,所以我从这篇文章中获得了一些灵感并打开了文件

gradle/wrapper/gradle-wrapper.properties

并添加了线条

systemProp.http.proxyHost=<my proxy>
systemProp.http.proxyPort=<my port>

我也用这个替换了 distributionUrl 行

distributionUrl=http\://services.gradle.org/distributions/gradle-2.13-bin.zip 

也就是说,我切换了 https --> http。

毕竟,我仍然得到相同的堆栈跟踪。

有人有建议吗?

编辑:我添加了一个

gradle.properties

主目录中的文件,并添加字段

systemProp.http.proxyHost
systemProd.http.proxyPort

systemProp.https.proxyHost
systemProp.https.proxyPort

但我仍然遇到与以前相同的错误。但是,构建脚本似乎停在这一行

Downloading https://services.gradle.org/distributions/gradle-2.13-bin.zip

大约 10 秒左右,在失败之前。所以……进步?

4

2 回答 2

3

我有同样的问题,2小时后终于找到了这个解决方案......

转到项目中的文件gradlew.bat并更改DEFAULT_JVM_OPTS变量,如下所示:

set DEFAULT_JVM_OPTS=-Dhttp.proxyHost=YOUR_HOST -Dhttp.proxyPort=PORT -Dhttp.proxyUser=USERNAME -Dhttp.proxyPassword=PASSWORD -Dhttps.proxyHost=YOUR_HOST -Dhttps.proxyPort=PORT -Dhttps.proxyUser=USERNAME -Dhttps.proxyPassword=PASSWORD

然后运行gradlew clean build

于 2019-08-02T10:13:08.507 回答
0

我不知道这是否是最佳解决方案,但最终对我有用的是替换

distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-bin.zip 

distributionUrl=https\://services.gradle.org/distributions/gradle-3.0-bin.zip

本质上是升级我正在抓取的 gradle 版本。

我还添加了一个全局

~/.gradle/gradle.properties

在我的主目录中,包含我之前声明的所有代理信息。我在这样做后尝试构建是不成功的,但我不能确定这样做是否会产生零影响。

于 2016-10-06T18:26:37.547 回答