简体   繁体   English

在 iOS 模拟器上启动 Flutter 应用程序时出错,应用程序崩溃

[英]Error Launching Flutter App on iOS Simulator, App Crashes

I am experiencing issues when launching a Flutter app on iOS simulator.我在 iOS 模拟器上启动 Flutter 应用程序时遇到问题。 The issue seems to be relating to localhost connectivity or Firebase, I am not able to tell.这个问题似乎与本地主机连接或 Firebase 有关,我无法分辨。 Judging by the below error put, but I am unable to find how to fix it.从下面的错误来看,但我无法找到解决方法。

I am running MacOS BigSur.我正在运行 MacOS BigSur。

The app launches and runs fine on the Android simulator counterpart.该应用程序在对应的 Android 模拟器上启动并运行良好。

Below is the error output from Android Studio Terminal:以下是来自 Android Studio 终端的错误 output:

Running pod install...
Running Xcode build...
Xcode build done.                                           716.3s
Configuring the default Firebase app...
Configured the default Firebase app __FIRAPP_DEFAULT.
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: OS Error: Connection refused, errno = 61, address = 127.0.0.1, port = 57172
This was attempt #50. Will retry in 0:00:01.600000.
Exception attempting to connect to the VM Service: SocketException: OS Error: Connection refused, errno = 61, address = 127.0.0.1, port = 57265
This was attempt #100. Will retry in 0:00:01.600000.
Exception attempting to connect to the VM Service: SocketException: OS Error: Connection refused, errno = 61, address = 127.0.0.1, port = 57356
This was attempt #150. Will retry in 0:00:01.600000.
Exception attempting to connect to the VM Service: SocketException: OS Error: Connection refused, errno = 61, address = 127.0.0.1, port = 57454
This was attempt #200. Will retry in 0:00:01.600000.
Exception attempting to connect to the VM Service: SocketException: OS Error: Connection refused, errno = 61, address = 127.0.0.1, port = 57586
This was attempt #250. Will retry in 0:00:01.600000.

I tried to fix this using some solutions online like the one on: Errors Launching Flutter app in iOS Simualtor我尝试使用一些在线解决方案来解决此问题,例如: Errors Launching Flutter app in iOS Simualtor

But that just removes the error from the Stack Trace(Android Studio Terminal) and the app still crashes.但这只是从堆栈跟踪(Android Studio 终端)中删除了错误,应用程序仍然崩溃。

Can someone please help?有人可以帮忙吗? Thank you!谢谢!

The error indicated that you have used firebase in-app but not initialized it try to initialize it by following steps in Appdelegate.swift file add该错误表明您在应用程序中使用了 firebase 但未对其进行初始化尝试按照 Appdelegate.swift 文件中的步骤进行初始化添加

  import Firebase //this line
   Bool{
    FirebaseApp.configure()//this line

in pod file inside pods在 pod 内的 pod 文件中

 target 'Runner' do
   pod 'Firebase/Analytics' //this line

and try to build again并尝试再次构建

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM