当我在 Visual Studio 代码中的调试控制台中运行我的 Flutter 应用程序时。我收到以下消息
"Launching lib\main.dart on AOSP on IA Emulator in debug mode...
√ Built build\app\outputs\flutter-apk\app-debug.apk.
Connecting to VM Service at ws://127.0.0.1:61843/B4tZiYo4ANE=/ws
I/madra.brew_cre(10170): Background concurrent copying GC freed 28317(6MB)
AllocSpace
objects, 5(96KB) LOS objects, 49% free, 1944KB/3MB, paused 1.286ms total 114.385ms
D/eglCodecCommon(10170): setVertexArrayObject: set vao to 0 (0) 1 0
D/EGL_emulation(10170): eglMakeCurrent: 0xe9586440: ver 2 0 (tinfo 0xd0ce8ff0)"
然后我在 socket_patch.dart 文件中收到错误
"Failed host lookup: '$host'"
但我注意到,当我从终端或 Android studio 运行相同的程序时。它构建成功,当我在运行时将其限制为观察端口时,它也构建得很好。当我在终端上运行与调试控制台上运行时的唯一区别是,当我从终端运行它时,它会自动在不同的端口上运行它。
"Launching lib\main.dart on AOSP on IA Emulator in debug mode...
Running Gradle task 'assembleDebug'... 9.7s
√ Built build\app\outputs\flutter-apk\app-debug.apk.
Syncing files to device AOSP on IA Emulator... 217ms
A Dart VM Service on AOSP on IA Emulator is available at:
http://127.0.0.1:62597/G44aJh3yYYE=/
The Flutter DevTools debugger and profiler on AOSP on IA Emulator is available at:
http://127.0.0.1:9101?uri=http://127.0.0.1:62597/G44aJh3yYYE=/
D/eglCodecCommon(10659): setVertexArrayObject: set vao to 0 (0) 1 0
D/EGL_emulation(10659): eglMakeCurrent: 0xd67fd2e0: ver 2 0 (tinfo 0xe7b2ac70)"
我以为我可能设置了代理设置或 http/https 环境变量,导致出现此行为,但我的系统设置为自动检测代理设置。
我遇到了同样的问题,它是否可以与以前的 dart 稳定版本一起返回,我希望对你有用。
flutter doctor -v
flutter channel stable
flutter upgrade
将
<uses-permission android:name="android.permission.INTERNET" />
添加到您的 AndroidManifest.xml
文件