You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter升级至3.7.7后资源文件无法加载问题求助

Flutter 3.7.7升级后资源加载失败问题

项目背景

  • 基于Flutter开发的项目,包含图片、字体、翻译文件等资源
  • pubspec.yaml中的资源配置如下:
assets:
  - assets/
  • 升级至Flutter 3.7.7版本前,资源加载一切正常

问题现象

  • 设备屏幕弹出错误提示:无法加载资源:"assets/translations/tr-TR.json"。资源不存在或数据为空。
  • 调试控制台未输出对应资源加载错误日志,但能看到Easy Localization的初始化及加载流程日志
  • assets文件夹下所有类型资源(图片、字体等)均出现同类加载失败问题

调试控制台输出

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!

Flutter 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!

已尝试的排查操作

  • 执行flutter clean命令清理项目后重新构建,问题未解决
  • 确认assets目录下所有资源文件均存在且数据完整无损坏

疑问

请问该问题的触发原因是什么?有哪些可行的解决方法可以让资源文件恢复正常加载?


内容的提问来源于stack exchange,提问作者Seyit Kılıç

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.27 15:10:00