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

VSCode中Flutter调试模式无法启动应用,Gradle assembleDebug失败

Fix for Flutter Debug Launch Failure on Android (Plus Root Cause Context)

The Exact Scenario (Matching Your Issue)

I had a fully working Flutter setup where launching apps via AVD or physical Android devices in VS Code debug mode was smooth—until suddenly it broke. The error I got was identical to yours:

Launching lib\main.dart on Android SDK built for x86 in debug mode... Gradle task assembleDebug failed with exit code 1 Exited (sigterm)

I ran through the standard checks first:

  • flutter doctor -v showed all environment configurations were completely normal
  • flutter run -v threw a "no connected devices" message, even though my AVD/physical device was clearly connected and recognized by Android Studio

The Quick Fix That Resolved Everything

After testing a few troubleshooting steps, this one command fixed the problem instantly:

flutter clean

Why This Worked (Likely Root Causes)

While we can't confirm the exact issue without deeper log analysis, this kind of unexplained failure almost always traces back to corrupted or conflicting build caches:

  • Damaged build artifacts: Previous builds may have left corrupted cache files in the project's build directory, causing Gradle to crash during the assembleDebug task
  • Stale device connection cache: Flutter sometimes caches device connection state; if this cache glitches, it can fail to recognize a connected device even when it's active
  • Temporary Gradle config conflicts: Minor dependency tweaks or project setting changes can leave Gradle in a broken state, and flutter clean wipes all these temporary states to start fresh

The flutter clean command deletes the project-wide build folder plus platform-specific build caches (like Android's .gradle directories), essentially resetting your project to a clean slate for building. It's the go-to fix for most weird, unexplained Flutter build failures.


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.11 08:31:01