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

运行Flutter示例应用时弹出构建失败报错,模拟器无法找到应用

Hey there, let's work through your Flutter setup issues step by step—this kind of hiccup is super common when you're just getting started, so I've got some practical fixes to try out.

Fixing the "FAILURE: Build failed with an exception" Error in VS Code

This error usually boils down to configuration mismatches or cached build data. Here's what to check:

  • Run flutter doctor to diagnose gaps
    Pop open the VS Code terminal and run flutter doctor—this tool will scan your entire setup and point out missing components, unaccepted licenses, or misconfigured paths. If you see red Xs next to Android-related items, run flutter doctor --android-licenses and follow the prompts to accept all required licenses.
  • Clean your project and rebuild from scratch
    Cached build files are a frequent culprit. Run these commands in order:
    flutter clean
    flutter pub get
    flutter run
    
    This wipes old build artifacts, reinstalls dependencies, and starts a fresh build.
  • Double-check your SDK paths in VS Code
    Open VS Code settings (Ctrl+, on Windows/Linux, Cmd+, on Mac), search for "Flutter SDK Path" and "Android SDK Path" to confirm they point to the correct folders where you installed these tools. If you're unsure where they live, flutter doctor will show you the expected paths.
  • Troubleshoot Gradle issues
    A lot of build failures tie to Gradle. Head to your project's android/gradle/wrapper/gradle-wrapper.properties file and make sure the Gradle version matches what your Flutter SDK expects. Also, ensure your internet is stable—Gradle often fails when it can't download required dependencies.

Fixing the Missing App in Android Emulator

If your emulator launches but the app is nowhere to be found, try these steps:

  • Confirm you're deploying to the right emulator
    When you run flutter run in VS Code, a list of available devices will pop up. Make sure you select the emulator that's currently running—sometimes VS Code defaults to a connected physical device or an emulator that hasn't fully loaded.
  • Uninstall leftover app instances
    Old cached app versions can block new builds. Open the emulator's app drawer, find any existing copies of your sample app, and uninstall them. You can also run flutter uninstall in the terminal to remove the app directly from the connected emulator.
  • Enable USB Debugging on the emulator
    Even emulators need this! Go to Settings > About Phone > Tap "Build Number" 7 times to unlock Developer Options, then go back to Settings > Developer Options and turn on USB Debugging. This lets Flutter properly push the app to the emulator.
  • Cold restart the emulator
    Emulators sometimes get stuck in a glitchy state. Close it completely, open Android Studio, launch the emulator again, and wait for it to fully load (give it a minute or two) before running flutter run again.

Give these fixes a try—most new Flutter devs resolve these issues with these steps. If you still hit walls, share the full error log from your VS Code terminal, and we can dig deeper!

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.07 22:23:13