【发布时间】:2019-11-27 03:40:19
【问题描述】:
使用 iOS 模拟器时无法加载图像资源。运行flutter run命令时总是会出现此错误,但是在我使用热重启(shift+r)重新运行后,所有图像资产都成功加载。如果我停止程序并再次使用 flutter run 命令重新运行,它仍然显示相同的错误。只有在 iOS 中运行时才会发生这种情况。
目前我使用的是稳定频道。
Flutter 1.7.8+hotfix.3 • channel stable • https://github.com/flutter/flutter.git
Framework • revision b712a172f9 (9 days ago) • 2019-07-09 13:14:38 -0700
Engine • revision 54ad777fd2
Tools • Dart 2.4.0
我已经尝试使用主频道仍然无法正常工作,再次返回稳定频道仍然无法正常工作。在运行 flutter run 命令之前,我还运行了 flutter clean 但它没有改变任何东西。
这是我的 pubspec.yaml 的样子。
flutter:
uses-material-design: true
assets:
- assets/images/
这是我在控制台中得到的。
flutter: ══╡ EXCEPTION CAUGHT BY IMAGE RESOURCE SERVICE ╞════════════════════════════════════════════════════
flutter: The following assertion was thrown resolving an image codec:
flutter: Unable to load asset: assets/images/logo_idbalap.png
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #0 PlatformAssetBundle.load
package:flutter/…/services/asset_bundle.dart:221
flutter: <asynchronous suspension>
flutter: #1 AssetBundleImageProvider._loadAsync
package:flutter/…/painting/image_provider.dart:464
flutter: <asynchronous suspension>
flutter: #2 AssetBundleImageProvider.load
package:flutter/…/painting/image_provider.dart:449
flutter: #3 ImageProvider.resolve.<anonymous closure>.<anonymous closure>.<anonymous closure>
package:flutter/…/painting/image_provider.dart:316
flutter: #4 ImageCache.putIfAbsent
package:flutter/…/painting/image_cache.dart:160
flutter: #5 ImageProvider.resolve.<anonymous closure>.<anonymous closure>
package:flutter/…/painting/image_provider.dart:316
flutter: (elided 13 frames from package dart:async)
flutter:
flutter: Image provider: AssetImage(bundle: null, name: "assets/images/logo_idbalap.png")
flutter: Image key: AssetBundleImageKey(bundle: PlatformAssetBundle#90c63(), name:
flutter: "assets/images/logo_idbalap.png", scale: 1.0)
flutter: ════════════════════════════════════════════════════════════════════════════════════════════════════
这是我的颤振医生 -v 回复。
[✓] Flutter (Channel stable, v1.7.8+hotfix.3, on Mac OS X 10.14 18A391, locale en-ID)
• Flutter version 1.7.8+hotfix.3 at /Users/fakhrinf/Development/flutter
• Framework revision b712a172f9 (9 days ago), 2019-07-09 13:14:38 -0700
• Engine revision 54ad777fd2
• Dart version 2.4.0
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at /Users/fakhrinf/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 10.0)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 10.0, Build version 10A255
• CocoaPods version 1.7.4
[✓] iOS tools - develop for iOS devices
• ios-deploy 1.9.4
[✓] Android Studio (version 3.4)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 37.0.1
• Dart plugin version 183.6270
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
[✓] VS Code (version 1.36.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.2.0
[✓] Connected device (1 available)
• iPhone 6 • 0271F90D-7FA8-4728-908A-25E08B56AC50 • ios • iOS 12.0 (simulator)
• No issues found!
最后我尝试卸载应用程序并再次运行flutter clean 和flutter run。我收到了这个错误。
Flutter crash report; please file at https://github.com/flutter/flutter/issues.
## command
flutter run
## exception
ProcessException: ProcessException: Process "/usr/bin/xcrun" exited abnormally:
An error was encountered processing the command (domain=IXUserPresentableErrorDomain, code=1):
This app could not be installed at this time.
Failed to load Info.plist from bundle at path /Users/fakhrinf/Library/Developer/CoreSimulator/Devices/0271F90D-7FA8-4728-908A-25E08B56AC50/data/Library/Caches/com.apple.mobile.installd.staging/temp.6jf6We/extracted/Payload/Runner.app
Failed to load Info.plist from bundle at path /Users/fakhrinf/Library/Developer/CoreSimulator/Devices/0271F90D-7FA8-4728-908A-25E08B56AC50/data/Library/Caches/com.apple.mobile.installd.staging/temp.6jf6We/extracted/Payload/Runner.app
Underlying error (domain=MIInstallerErrorDomain, code=35):
Failed to load Info.plist from bundle at path /Users/fakhrinf/Library/Developer/CoreSimulator/Devices/0271F90D-7FA8-4728-908A-25E08B56AC50/data/Library/Caches/com.apple.mobile.installd.staging/temp.6jf6We/extracted/Payload/Runner.app
Command: /usr/bin/xcrun simctl install 0271F90D-7FA8-4728-908A-25E08B56AC50 /Users/fakhrinf/Development/Mobile/idbalapflutter/build/ios/iphonesimulator/Runner.app
#0 runCheckedAsync (package:flutter_tools/src/base/process.dart:259:7)
<asynchronous suspension>
#1 SimControl.install (package:flutter_tools/src/ios/simulators.dart:128:16)
#2 IOSSimulator._setupUpdatedApplicationBundle (package:flutter_tools/src/ios/simulators.dart:415:31)
<asynchronous suspension>
#3 IOSSimulator.startApp (package:flutter_tools/src/ios/simulators.dart:315:15)
<asynchronous suspension>
#4 FlutterDevice.runHot (package:flutter_tools/src/resident_runner.dart:371:54)
#5 _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:77:64)
#6 _rootRunUnary (dart:async/zone.dart:1132:38)
#7 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#8 _FutureListener.handleValue (dart:async/future_impl.dart:126:18)
#9 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:639:45)
#10 Future._propagateToListeners (dart:async/future_impl.dart:668:32)
#11 Future._complete (dart:async/future_impl.dart:473:7)
#12 _SyncCompleter.complete (dart:async/future_impl.dart:51:12)
#13 _AsyncAwaitCompleter.complete.<anonymous closure> (dart:async-patch/async_patch.dart:33:20)
#14 _rootRun (dart:async/zone.dart:1120:38)
#15 _CustomZone.run (dart:async/zone.dart:1021:19)
#16 _CustomZone.runGuarded (dart:async/zone.dart:923:7)
#17 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:963:23)
#18 _rootRun (dart:async/zone.dart:1124:13)
#19 _CustomZone.run (dart:async/zone.dart:1021:19)
#20 _CustomZone.runGuarded (dart:async/zone.dart:923:7)
#21 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:963:23)
#22 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#23 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#24 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:116:13)
#25 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:173:5)
【问题讨论】:
-
在第一次运行
flutter run之前尝试从模拟器中删除应用程序。 -
我尝试过,但又遇到了另一个令人震惊的崩溃错误。
Oops; flutter has exited unexpectedly. Sending crash report to Google.我尝试再次运行它,崩溃错误消失了,但我的图片资源仍然没有显示,并出现上述相同的错误。