非常狗屎
报错提示是这样:
Exception in thread "main" java.net.SocketException: Unexpected end of file from server
at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:851)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:678)
at sun.net.www.protocol.http.HttpURLConnection.doTunneling(HttpURLConnection.java:2055)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:183)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1564)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:263)
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)
Finished with error: Gradle task assembleDebug failed with exit code 1
网上所有的对 gradle 加 proxy, 或者改为阿里镜像的方法一概没有作用
查看项目目录下 android/gradle/wrapper/
看到这句:
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
拿到了下载地址是 https://services.gradle.org/distributions/gradle-5.6.2-all.zip
进入 :
/Users/lyseky/.gradle/wrapper/dists/gradle-5.6.2-all/9st6wgf78h16so49nn74lgtbb
目录, 直接用wget手动下载
wget https://services.gradle.org/distributions/gradle-5.6.2-all.zip
重新启动, 搞定了
如果是 socks5 代理 ,如下这样设置其实并没有什么卵用
#systemProp.socks.proxyHost=127.0.0.1
#systemProp.socks.proxyPort=7077
#systemProp.https.proxyHost=127.0.0.1
#systemProp.https.proxyPort=7077
#systemProp.https.proxyHost=socks5://127.0.0.1
#systemProp.https.proxyPort=7077
怎样处理Gradle中的这个文件下载慢的问题的?
正确设置方法应该是这样:
org.gradle.jvmargs=-DsocksProxyHost=127.0.0.1 -DsocksProxyPort=7070
修改 $HOME/.gradle/gradle.properties 文件,加入上面那句,这样就可以全局开启 gradle 代理