问题描述:Android Studio中, 左上角flutter device selection选择chrome web,使用浏览器运行flutter web应用, 报错:
Launching lib\main.dart on Chrome in debug mode...
Finished with error: Failed to bind web development server:
SocketException: Failed to create server socket (OS Error: Failed to start accept), address = localhost, port = 2937
解决:
Windows环境下,需要添加--web-hostname=127.0.0.1。添加后执行代码如下:
flutter run -d chrome --web-hostname=127.0.0.1- 其他环境下,需要添加
--web-port=8080 --web-hostname=127.0.0.1(端口可以填其他未被占用端口号)。添加后执行代码如下:
flutter run -d chrome --web-port=8080 --web-hostname=127.0.0.1 - 如果想要在
Android Studio里运行以使用热更新,需要如下修改:
打开Edit configurations界面,找到你运行项目的Additional run args增加参数:--web-hostname=127.0.0.1(Windows环境下)或者--web-port=8080 --web-hostname=127.0.0.1(其他环境)

1万+

被折叠的 条评论
为什么被折叠?



