I have a Flutter project where I use some asset files such as images, fonts, and translations. I have defined them in my pubspec.yaml file like this:
assets:
- assets/
Until a few hours ago, everything was working fine. However, after updating my Flutter version to 3.7.7, I started getting an error message "Unable to load asset: "assets/translations/tr-TR.json". The asset does not exist or has empty data." in my phone screen, but I'm not seeing any error message in the console.
There is phone screen:
There is debug console:
Launching lib\main.dart on sdk gphone64 x86 64 in debug mode...
main.dart:1
ā Built build\app\outputs\flutter-apk\app-debug.apk.
Connecting to VM Service at ws://127.0.0.1:57800/FoEH_6WcISk=/ws
I/om.example.azar( 4117): Background concurrent copying GC freed 74693(4611KB) AllocSpace objects, 34(1000KB) LOS objects, 49% free, 4129KB/8259KB, paused 7.543ms,196us total 146.684ms
D/CompatibilityChangeReporter( 4117): Compat change id reported: 183155436; UID 10159; state: ENABLED
I/FirebaseApp( 4117): Device unlocked: initializing all Firebase APIs for app [DEFAULT]
D/FirebaseAuth( 4117): Notifying id token listeners about user ( Z3oPDIDlWVcCcvVNQmVICLNHvRo1 ).
D/TrafficStats( 4117): tagSocket(131) with statsTag=0x8003, statsUid=-1
W/FlutterJNI( 4117): FlutterJNI.loadLibrary called more than once
I/ResourceExtractor( 4117): Found extracted resources res_timestamp-1-1678988753313
W/FlutterJNI( 4117): FlutterJNI.prefetchDefaultFontManager called more than once
W/FlutterJNI( 4117): FlutterJNI.init called more than once
I/FLTFireBGExecutor( 4117): Creating background FlutterEngine instance, with args: [--start-paused, --enable-dart-profiling]
D/EGL_emulation( 4117): eglCreateContext: 0x7426e73dfc50: maj 2 min 0 rcv 2
D/EGL_emulation( 4117): eglCreateContext: 0x7426e73e09d0: maj 2 min 0 rcv 2
D/HostConnection( 4117): createUnique: call
D/HostConnection( 4117): HostConnection::get() New Host Connection established 0x7426e73da490, tid 4412
D/HostConnection( 4117): HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_vulkan ANDROID_EMU_deferred_vulkan_commands ANDROID_EMU_vulkan_null_optional_strings ANDROID_EMU_vulkan_create_resources_with_requirements ANDROID_EMU_YUV_Cache ANDROID_EMU_vulkan_ignored_handles ANDROID_EMU_has_shared_slots_host_memory_allocator ANDROID_EMU_vulkan_free_memory_sync ANDROID_EMU_vulkan_shader_float16_int8 ANDROID_EMU_vulkan_async_queue_submit ANDROID_EMU_vulkan_queue_submit_with_commands ANDROID_EMU_sync_buffer_data ANDROID_EMU_read_color_buffer_dma ANDROID_EMU_hwc_multi_configs GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_gles_max_version_2
D/EGL_emulation( 4117): eglMakeCurrent: 0x7426e73e09d0: ver 2 0 (tinfo 0x742906c01280) (first time)
I/flutter ( 4117): [š Easy Localization] [DEBUG] Localization initialized
I/flutter ( 4117): [š Easy Localization] [DEBUG] Start
I/flutter ( 4117): [š Easy Localization] [DEBUG] Init state
I/flutter ( 4117): [š Easy Localization] [INFO] Saved locale loaded tr_TR
I/flutter ( 4117): [š Easy Localization] [DEBUG] Build
I/flutter ( 4117): [š Easy Localization] [DEBUG] Init Localization Delegate
I/flutter ( 4117): [š Easy Localization] [DEBUG] Init provider
I/flutter ( 4117): [š Easy Localization] [DEBUG] Load Localization Delegate
I/flutter ( 4117): [š Easy Localization] [DEBUG] Load asset from assets/translations
I/FLTFireMsgService( 4117): FlutterFirebaseMessagingBackgroundService started!
I/flutter ( 4117): [š Easy Localization] [DEBUG] Build
E/SurfaceSyncer( 4117): Failed to find sync for id=0
W/Parcel ( 4117): Expecting binder but got null!
There is my doctor:
Doctor summary (to see all details, run flutter doctor -v):
[ā] Flutter (Channel stable, 3.7.7, on Microsoft Windows [Version 10.0.22621.1413], locale tr-TR)
[ā] Windows Version (Installed version of Windows is version 10 or higher)
[ā] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
[ā] Chrome - develop for the web
[ā] Visual Studio - develop for Windows (Visual Studio Community 2022 17.4.4)
[ā] Android Studio (version 2022.1)
[ā] IntelliJ IDEA Community Edition (version 2022.3)
[ā] VS Code (version 1.76.2)
[ā] Connected device (4 available)
[ā] HTTP Host Availability
ā¢ No issues found!
I have tried the flutter clean
command, but it didn't solve the problem. I also made sure that the files exist and have proper data in them. Interestingly, I'm getting the same error for all of the files in the assets folder, including images, fonts, etc.
What could be the cause of this issue? How can I solve it and make my asset files load properly again?
Thanks in advance for any help.
According to mobile Error your pubspec.yaml assets path not correct.Add this -assets/translations/ below -assets/
assets:
- assets/
- assets/translations/