Flutter-iOS模拟器未加载资产

时间:2019-07-18 08:46:44

标签: ios flutter

使用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 cleanflutter 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)

1 个答案:

答案 0 :(得分:0)

在通过尝试许多事情来解决我的flutter项目以解决负载资产问题后,我决定用创建时带有--androidx标志的新flutter项目对其进行测试。我不确定是否会影响iOS中的任何内容,但是在将旧项目迁移到androidx并将其发布到playstore后,我的项目在iOS中成为错误。

创建新项目后,我复制了旧的pubspec.yaml资产文件夹 lib文件夹,并且有效! < / p>