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

Flutter构建APK时抛出AOT快照生成器错误(错误码-1073741819)

Flutter 3.29.2 AOT编译失败(错误码-1073741819)解决方案

问题概述

使用Flutter 3.29.2稳定版构建APK时,AOT快照生成失败,抛出错误码-1073741819(Windows平台内存访问异常)。此前该版本可正常构建,已尝试flutter clean、删除.dart_tool/build目录、flutter pub get、--no-tree-shake-icons等操作,均未解决问题。

报错日志

常规构建日志

PS D:\AndroidStudiosProjects\nccs_projects\nccs_pos> flutter build apk
Dart snapshot generator failed with exit code -1073741819
Font asset "MaterialIcons-Regular.otf" was tree-shaken, reducing it from 1645184 to 7160 bytes (99.6% reduction). Tree-shaking can be disabled by providing the --no-tree-shake-icons flag when building your app.
Target android_aot_release_android-arm failed: Exception: AOT snapshotter exited with code -1073741819


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileFlutterBuildRelease'.
> Process 'command 'D:\Program Files\flutter\bin\flutter.bat'' finished with non-zero exit value 1

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 11s
Running Gradle task 'assembleRelease'...                           12.3s
Gradle task assembleRelease failed with exit code 1

添加--no-tree-shake-icons后日志

PS D:\AndroidStudiosProjects\nccs_projects\nccs_pos> flutter build apk --no-tree-shake-icons
Dart snapshot generator failed with exit code -1073741819
Font asset "MaterialIcons-Regular.otf" was tree-shaken, reducing it from 1645184 to 7160 bytes (99.6% reduction). Tree-shaking can be disabled by providing the --no-tree-shake-icons flag when building your app.
Target android_aot_release_android-arm failed: Exception: AOT snapshotter exited with code -1073741819


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileFlutterBuildRelease'.
> Process 'command 'D:\Program Files\flutter\bin\flutter.bat'' finished with non-zero exit value 1

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 11s
Running Gradle task 'assembleRelease'...                           12.3s
Gradle task assembleRelease failed with exit code 1

Flutter Doctor 结果

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.29.2, on Microsoft Windows [Version 10.0.26100.3476], locale en-US)
[√] Windows Version (Windows 11 or higher, 24H2, 2009)
[√] Android toolchain - develop for Android devices (Android SDK version 36.0.0)
[√] Chrome - develop for the web
[X] Visual Studio - develop Windows apps
    X Visual Studio not installed; this is necessary to develop Windows apps.
      Download at https://visualstudio.microsoft.com/downloads/.
      Please install the "Desktop development with C++" workload, including all of its default components
[√] Android Studio (version 2024.2)
[√] Android Studio (version 2024.3)
[√] Connected device (4 available)
[√] Network resources

! Doctor found issues in 1 category.

解决方案

  • 修复Dart依赖缓存:执行flutter pub cache repair,重新校验并下载所有依赖包缓存,解决缓存损坏引发的编译异常。
  • 指定构建架构:尝试仅构建arm64架构,执行flutter build apk --target-platform android-arm64;或拆分ABI构建flutter build apk --split-per-abi,排查单一架构的编译兼容性问题。
  • 临时禁用代码混淆:修改android/app/build.gradle,将minifyEnabled true和shrinkResources true改为false,重新构建,排除混淆过程触发的内存错误。
  • 释放系统资源:关闭浏览器、其他IDE等内存占用高的程序,或增大Windows虚拟内存,AOT编译对内存资源要求较高,资源不足可能导致崩溃。
  • 彻底重装Flutter SDK:备份项目pubspec.yaml后,删除当前Flutter SDK目录,重新下载3.29.2稳定版并配置环境变量,执行flutter doctor确认环境正常后重新拉取依赖。
  • 排查可疑代码/依赖:检查近期新增的依赖或代码,尤其是使用dart:mirrors反射、动态生成代码的部分,AOT编译对这类代码兼容性较差,可逐个注释排查。

内容的提问来源于stack exchange,提问作者Peaky Prodigy

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.13 18:47:05