Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter - iOS emulator not loading assets

Tags:

ios

flutter

Image assets unable to load when using iOS simulator. This error always happen when running flutter run command, but after I re-run using hot restart (shift+r) all image assets load successfully. If I stop the program and re-run using flutter run command again, it's still showing the same error. This is only happen when running in iOS.

Currently i'm using stable channel.

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

I've already tried using master channel still not working, return back to stable channel again still not working either. Before running flutter run command I also running flutter clean but it's not changing anything.

This is my pubspec.yaml looks like.

flutter:
  uses-material-design: true
  assets:
    - assets/images/

this is what i get in the console.

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: ════════════════════════════════════════════════════════════════════════════════════════════════════

this is my flutter doctor -v response.

[✓] 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!

Lastly I try to uninstall the app and run flutter clean and flutter run again. I got this error.

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)
like image 464
Fakhri Nurfauzan Avatar asked Dec 20 '25 23:12

Fakhri Nurfauzan


1 Answers

After many times dirty my flutter project by trying many things to solve the load assets issues, I decided to test it with new flutter project with --androidx flag on creation. I'm not really sure if it will affect anything in iOS but my project become error in iOS after I migrate my old project to androidx and publish it to playstore.

After creating the new project I copy my old pubspec.yaml, assets folder and lib folder, and it's works!

like image 141
Fakhri Nurfauzan Avatar answered Dec 22 '25 13:12

Fakhri Nurfauzan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!