龙空技术网

Flutter运行报Connection timed out: connect异常怎么解决?

触心语录 142

前言:

当前看官们对“python ssl socket 服务器不稳定”大体比较讲究,朋友们都需要剖析一些“python ssl socket 服务器不稳定”的相关知识。那么小编也在网上搜集了一些有关“python ssl socket 服务器不稳定””的相关资讯,希望各位老铁们能喜欢,你们一起来学习一下吧!

搬砖的一天开始了

学习flutter ,新建了一个项目,想要将项目运行到夜神安卓模拟器当中,开发工具使用的是vscode,vscode已经正常连接模拟器,运行报如下异常。。。。

PS D:\workspace\flutter-space\startup_namer> flutter runLaunching lib\main.dart on OPPO R11 Plus in debug mode...Running Gradle task 'assembleDebug'...Exception in thread "main" java.net.ConnectException: Connection timed out: connect        at java.net.DualStackPlainSocketImpl.connect0(Native Method)        at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)        at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)        at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)        at java.net.Socket.connect(Socket.java:607)        at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:666)        at sun.security.ssl.BaseSSLSocketImpl.connect(BaseSSLSocketImpl.java:173)        at sun.net.NetworkClient.doConnect(NetworkClient.java:180)        at sun.net.        at sun.net.        at sun.net.;init>(HttpsClient.java:264)        at sun.net.        at sun.net.        at sun.net.        at sun.net.        at sun.net.        at sun.net.        at sun.net.        at sun.net.        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)Running Gradle task 'assembleDebug'...                             22.2sException: Gradle task assembleDebug failed with exit code 1

通过以上异常信息可以发现应该是在Gradle构建项目时报错,有安卓开发经验应该知道Gradle的下载经常是非常慢的,还经常下载不成功。打开gradle-wrapper.properties 内容如下

#Fri Jun 23 08:50:38 CEST 2017distributionBase=GRADLE_USER_HOMEdistributionPath=wrapper/distszipStoreBase=GRADLE_USER_HOMEzipStorePath=wrapper/distsdistributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip

推测项目应该是无法找到GRADLE_USER_HOME,而且系统也没有设置GRADLE_USER_HOME的环境变量,于是配置环境变量,我的gradle是放在D盘

环境变量配置

配置完成之后,重新flutter run...

重跑之后发现gradle的报错已经没有了,但是又报如下ndk错误...

Execution failed for task ':app:stripDebugDebugSymbols'.> NDK at D:\soft\android-sdk-windows\ndk-bundle did not have a source.properties file

心中浮现了三只草泥马

项目找不到ndk于是打开安卓内的local.properties

flutter.sdk=D:\\soft\\flutter\\fluttersdk.dir=D:\\soft\\android-sdk-windowsflutter.buildMode=debugflutter.versionName=1.0.0flutter.versionCode=1

flutter和sdk配置都没有错,回到sdk目录查看目录如下。。。

安卓sdk目录

什么时候有这么多个ndk文件夹了,可能不设置系统默认找ndk-bundle,但是我下载的ndk其实是被放到了ndk文件夹中了,于是在local.properties中添加一行配置,告诉它去这里找ndk

ndk.dir=D:\\soft\\android-sdk-windows\\ndk\\23.0.7599858

23.0.7599858是应该是ndk的版本。。。报错还有可能是ndk没有下载哦!!!!

重新运行又报错了,但是感觉离成功越来越近了

PS D:\workspace\flutter-space\startup_namer> flutter runLaunching lib\main.dart on OPPO R11 Plus in debug mode...Running Gradle task 'assembleDebug'...                              9.6s√  Built build\app\outputs\flutter-apk\app-debug.apk.Installing build\app\outputs\flutter-apk\app.apk...                 4.9sProcessException: Process exited abnormally:error: protocol fault (couldn't read status): Connection reset by peer  Command: D:\soft\android-sdk-windows\platform-tools\adb.exe -s 127.0.0.1:62001 shell am start -a android.intent.action.RUN -f 0x20000000 --ez enable-background-compilation true --ez  enable-dart-profiling true --ez enable-checked-mode true --ez verify-entry-points true com.example.startup_namer/com.example.startup_namer.MainActivity

草泥马的漠视

看一下好像是adb的错,可能跟项目没有关系,重跑一次就可以了。

于是我又开始愉快地搬砖了。。。

继续搬

标签: #python ssl socket 服务器不稳定