VS Code启动Flutter应用遇VM Service连接失败及崩溃问题求助
Flutter iOS模拟器启动崩溃(VM Service连接失败)
在VS Code中启动Flutter应用到iPhone 15 Pro模拟器,或执行flutter run命令时,Xcode构建完成后出现VM Service连接拒绝错误,应用直接崩溃。具体报错信息如下:
命令行报错日志
Launching lib/main.dart on iphone 15 pro in debug mode... Running Xcode build... └─Compiling, linking and signing... 9,4s Xcode build done. 36,5s FFmpegKitFlutterPlugin 0x60000024b6e0 created. Connecting to the VM Service is taking longer than expected... Still attempting to connect to the VM Service... If you do NOT see the Flutter application running, it might have crashed. The device logs (e.g. from adb or XCode) might have more details. If you do see the Flutter application running on the device, try re-running with --host-vmservice-port to use a specific port known to be available. Exception attempting to connect to the VM Service: SocketException: Connection refused (OS Error: Connection refused, errno = 61), address = 127.0.0.1, port = 57364 This was attempt #50. Will retry in 0:00:01.600000. Exception attempting to connect to the VM Service: SocketException: Connection refused (OS Error: Connection refused, errno = 61), address = 127.0.0.1, port = 57429 This was attempt #100. Will retry in 0:00:01.600000. Exception attempting to connect to the VM Service: SocketException: Connection refused (OS Error: Connection refused, errno = 61), address = 127.0.0.1, port = 57480 This was attempt #150. Will retry in 0:00:01.600000. FFmpegKitFlutterPlugin 0x60000022b600 created. Exception attempting to connect to the VM Service: SocketException: Connection refused (OS Error: Connection refused, errno = 61), address = 127.0.0.1, port = 57548 This was attempt #200. Will retry in 0:00:01.600000. Exception attempting to connect to the VM Service: SocketException: Connection refused (OS Error: Connection refused, errno = 61), address = 127.0.0.1, port = 57601 This was attempt #250. Will retry in 0:00:01.600000.
崩溃日志
Incident Identifier: 344F78C3-E3BF-400A-AE76-759C5B33AF6C CrashReporter Key: 323C7BED-0B9E-DB11-9F22-448164A6CA0A Hardware Model: MacBookAir10,1 Process: Runner [16290] Path: /Users/USER/Library/Developer/CoreSimulator/Devices/4F362091-DC33-4F15-91DD-8EB6D1F63DC5/data/Containers/Bundle/Application/6786C2CA-9B1A-417D-A6F5-272D22D29999/Runner.app/Runner Identifier: kz.videopokaz.videopokazApp Version: 1.0.0 (1) Code Type: ARM-64 (Native) Role: Foreground Parent Process: launchd_sim [93290] Coalition: com.apple.CoreSimulator.SimDevice.4F362091-DC33-4F15-91DD-8EB6D1F63DC5 [28527] Responsible Process: SimulatorTrampoline [1095] Date/Time: 2024-09-05 02:23:55.9044 +0500 Launch Time: 2024-09-05 02:23:54.5494 +0500 OS Version: macOS 14.6.1 (23G93) Release Type: User Report Version: 104 Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Termination Reason: SIGNAL 6 Abort trap: 6 Terminating Process: Runner [16290] Triggered by Thread: 0
排查解决方案
- 清理项目缓存
- 执行
flutter clean - 进入ios目录,删除
Pods文件夹和Podfile.lock - 执行
pod install
- 执行
- 重置模拟器
打开模拟器,点击菜单栏Device->Erase All Content and Settings,完成后重启模拟器 - 指定VM Service端口启动
执行flutter run --host-vmservice-port 8888(可替换为其他未占用端口) - 检查FFmpegKitFlutterPlugin兼容性
确认插件版本与当前Flutter、Xcode版本匹配,尝试更新插件到最新稳定版 - 验证Xcode配置
打开ios/Runner.xcworkspace,检查签名配置是否正确,模拟器部署目标版本与项目pubspec.yaml中的配置一致 - 重启开发环境
关闭VS Code、模拟器、Xcode,重新打开后再尝试启动应用
内容的提问来源于stack exchange,提问作者Tap tap
相关产品推荐
相关产品推荐

