今天在跑flutter项目的时候发现run的时候最后报了个错,websocket连不上,导致无法进行热更新。具体现象如下:
D:\Development\Code\xxx>flutter run
Using hardware rendering with device Android SDK built for x86. If you get graphics artifacts, consider enabling software rendering with "--enable-software-rendering".
Launching lib/main.dart on Android SDK built for x86 in debug mode…
Initializing gradle… 1.0s
Resolving dependencies… 4.1s
Running Gradle task 'assembleDebug'…
Running Gradle task 'assembleDebug'… Done 12.2s
Built build\app\outputs\apk\debug\app-debug.apk.
I/Choreographer(18513): Skipped 64 frames! The application may be doing too much work on its main thread.
D/EGL_emulation(18513): eglMakeCurrent: 0xe6885660: ver 3 0 (tinfo 0xe6883de0)
I/OpenGLRenderer(18513): Davey! duration=1305ms; Flags=1, IntendedVsync=36199902452578, Vsync=36200969119202, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=36200984383400, AnimationStart=36200987058300,
PerformTraversalsStart=36200987082200, DrawStart=36200994558400, SyncQueued=36200995284100, SyncStart=36201101340000, IssueDrawCommandsStart=36201101874700, SwapBuffers=36201266596000, FrameCompleted=36201314412700, DequeueBufferDur
ation=26981000, QueueBufferDuration=1940000,
D/EGL_emulation(18513): eglMakeCurrent: 0xe4a7ad20: ver 3 0 (tinfo 0xe4a7d780)
Syncing files to device Android SDK built for x86… 1,961ms
Error connecting to the service protocol: HttpException: Connection closed before full header was received, uri = http://127.0.0.1:58575/4W7jgszrNuo=/ws
一开始以为是代理的问题,关了之后发现依然存在。 Flutter Doctor诊断了一下没有任何异常。网上有人说flutter热更新服务依赖于python2.7,于是我又装上了python,但依然没见效。
最后索性装了个android pie( API28 )的模拟器,再run就自动好了。flutter还是很多不靠谱之处啊。。。