flutter编译错误 [ +91 ms] Exception in thread “main“ java.net.SocketException: Unexpected end of file f

flutter build apk 是出错:

[  +91 ms] Exception in thread "main" java.net.SocketException: Unexpected end of file from server
[        ] 	at java.base/sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:936)
[        ] 	at java.base/sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:759)
[        ] 	at java.base/sun.net.www.protocol.http.HttpURLConnection.doTunneling0(HttpURLConnection.java:2174)
[        ] 	at java.base/sun.net.www.protocol.http.HttpURLConnection.doTunneling(HttpURLConnection.java:2136)
[        ] 	at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
[        ] 	at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1665)
[        ] 	at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1589)
[        ] 	at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:224)
[        ] 	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-5.6.2-all.zip下载失败
解决方案:

本人修改~/.gradle/gradle.properties 发现里面有代理设置,注释掉正常了。

org.gradle.parallel=true

#Sun Aug 27 10:40:02 CST 2023
#systemProp.http.proxyHost=127.0.0.1
#systemProp.http.proxyPort=7891
#systemProp.https.proxyHost=127.0.0.1
#systemProp.https.proxyPort=7891
~

window下:

手动下载Gradle:比如可以参考https://blog.csdn.net/chrisyuu/article/details/52711025
当然,我最后发现,我这个问题的原因是因为在我的C:/Users//.gradle/gradle.properties(不是项目下的gradle.properities)中有几行多余的代理设置,删掉就好了……如果有人遇到相同的问题也可以查看一下这个文件~

参考链接:https://www.jianshu.com/p/5aa8c2fbd3d1

你可能感兴趣的:(flutter,java,.net)