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

Windows环境下Flutter基础应用无法运行的技术求助

Flutter项目在Windows环境无法启动的问题

问题概述

已完成Flutter与VS Code的安装配置,创建新Flutter项目后,手机端和浏览器端均无法正常启动。该问题仅出现在Windows环境,Ubuntu下可正常运行。

项目创建时的输出

[flutter_application_1] flutter create --template app --overwrite .
Creating project .... Resolving dependencies... Got dependencies.
Wrote 129 files.

All done! You can find general documentation for Flutter, detailed API documentation, and video documentation via official channels.

In order to run your application, type:

$ cd . $ flutter run

Your application code is in .\lib\main.dart.

exit code 3221225501

手机端启动报错

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:compileFlutterBuildDebug'.

Process 'command 'F:\f\bin\flutter.bat'' finished with non-zero exit value -1073741795

  • 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 via official Gradle documentation

BUILD FAILED in 48s Running Gradle task 'assembleDebug'...

浏览器端启动报错

flutter run -d Chrome Launching lib\main.dart on Chrome in debug
mode... Waiting for connection from debug service on Chrome...

补充说明

曾尝试使用Android Studio,创建项目时会报错,重启Android Studio后可运行Web应用,但Android应用仍出现上述相同报错。

flutter doctor -v 输出

[√] Flutter (Channel stable, 3.19.2, on Microsoft Windows [Version
10.0.19045.4046], locale en-IN)
    • Flutter version 3.19.2 on channel stable at F:\f
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 7482962148 (11 days ago), 2024-02-27 16:51:22 -0500
    • Engine revision 04817c99c9
    • Dart version 3.3.0
    • DevTools version 2.31.1

[√] Windows Version (Installed version of Windows is version 10 or higher)  

[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at F:\androidsdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: F:\Android\android studio\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-b2043.56-10550314)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[X] Visual Studio - develop Windows apps
    X Visual Studio not installed; this is necessary to develop Windows apps.
      Download via official Visual Studio downloads page.
      Please install the "Desktop development with C++" workload, including all of its default components

[√] Android Studio (version 2023.1)
    • Android Studio at F:\Android\android studio
    • Flutter plugin and Dart plugin can be installed via JetBrains plugin marketplace.
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-b2043.56-10550314)

[√] VS Code (version 1.87.1)
    • VS Code at C:\Users\chaitanya\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.84.0

[√] Connected device (4 available)
    • moto g32 (mobile) • 192.168.29.6:43373 • android-arm64  • Android 13 (API 33)
    • Windows (desktop) • windows            • windows-x64    • Microsoft Windows [Version 10.0.19045.4046]
    • Chrome (web)      • chrome             • web-javascript • Google Chrome 122.0.6261.95
    • Edge (web)        • edge               • web-javascript • Microsoft Edge 122.0.2365.66

[√] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.

解决方案

针对Windows环境下的这类报错(exit code 3221225501、-1073741795),按以下步骤排查:

1. 修复Flutter安装文件

执行命令修复可能损坏的文件与依赖:

flutter clean
flutter pub get
flutter doctor --repair

2. 排查杀毒软件拦截

这类报错常由杀毒软件阻断Flutter进程导致:

  • 临时关闭Windows Defender实时保护或第三方杀毒软件,重试运行项目
  • 将Flutter安装目录(F:\f)、Android SDK目录(F:\androidsdk)加入杀毒软件白名单

3. 调整Gradle内存配置

打开项目内android\gradle.properties文件,修改JVM内存参数:

org.gradle.jvmargs=-Xmx1536M

若无效,尝试调整为-Xmx2048M或-Xmx3072M

4. 切换Flutter通道测试

尝试切换到beta通道验证问题是否存在:

flutter channel beta
flutter upgrade

若问题解决,后续可切回稳定通道;若仍报错,切回稳定通道后重新执行flutter upgrade

5. 以管理员身份运行IDE

确保VS Code或Android Studio以管理员权限启动,避免因系统权限不足导致进程执行失败

6. 修复Windows系统文件

执行系统文件检查命令,修复可能损坏的系统组件:

sfc /scannow

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.28 12:58:10