为什么我的Flutter应用程序不能在iPhone上运行?



我成功地在模拟器上运行了我的应用程序(iPhone 12, iOS 14.5),但是当它在真正的iPhone 11 Pro Max(iOS 14.7.1)上运行时,我面对的只是一个黑屏。下面是Xcode的输出:

2021-09-16 18:48:00.155232+0300 Runner[2396:1009680] Metal API Validation Enabled 
2021-09-16 18:48:00.244991+0300 Runner[2396:1009680] Could not load the "LaunchImage" image referenced from a nib in the bundle with identifier "xxx.yyy.zzz" 
2021-09-16 18:48:00.353909+0300 Runner[2396:1009946] [VERBOSE-2:shell.cc(93)] Dart Error: Can't load Kernel binary: Invalid kernel binary format version. 
2021-09-16 18:48:00.354015+0300 Runner[2396:1009946] [VERBOSE-2:dart_isolate.cc(170)] Could not prepare isolate. 
2021-09-16 18:48:00.354185+0300 Runner[2396:1009946] [VERBOSE-2:runtime_controller.cc(382)] Could not create root isolate. 
2021-09-16 18:48:00.354213+0300 Runner[2396:1009946] [VERBOSE-2:shell.cc(576)] Could not launch engine with configuration. 
2021-09-16 18:48:00.367242+0300 Runner[2396:1009960] flutter: Observatory listening on http://127.0.0.1:54273/PrvtvZOQ8Wc=/

颤振医生:

[✓] Flutter (Channel stable, 2.2.3, on macOS 11.5.2 20G95 darwin-x64, locale
ru-BY)
[✗] Android toolchain - develop for Android devices
✗ Unable to locate Android SDK.
Install Android Studio from:
https://developer.android.com/studio/index.html
On first launch it will assist you in installing the Android SDK
components.
(or visit https://flutter.dev/docs/get-started/install/macos#android-setup
for detailed instructions).
If the Android SDK has been installed to a custom location, please use
flutter config --android-sdk to update to that location.
[✓] Xcode - develop for iOS and macOS
[✗] Chrome - develop for the web (Cannot find Chrome executable at
/Applications/Google Chrome.app/Contents/MacOS/Google Chrome)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[!] Android Studio (not installed)
[✓] Connected device (2 available)

Xcode 12.5.1


更新要解决这个问题,请删除运行rm -rf ~/flutter/bin/cache。然后运行flutter run(你应该从终端而不是IDE运行你的应用程序,以便Flutter下载丢失的文件)。现在总算可以用了。

使用rm -rf ~/flutter/bin/cache删除缓存对我有效。此问题似乎是由不良的Flutter安装引起的。删除缓存后运行flutter pub get,需要重新下载包,重新构建项目。

最新更新