vscode调试flutter App报错

Display an error while debug the flutter App in vscode

我无法在 Vscode 中调试我的 Flutter 应用程序,DEBUG CONSOL 返回:

Unable to locate a development device; please run 'flutter doctor' for information about installing additional components.

我可以在 运行 之后显示我的模拟器:

flutter emulators

我可以 运行 :

flutter emulators --launch 4.7_WXGA_API_22

flutter doctor -v :

[✓] Flutter (Channel stable, v1.7.8+hotfix.4, on Linux, locale en_US.UTF-8)
    • Flutter version 1.7.8+hotfix.4 at /home/ZZZ/Dev/Flutter/flutter
    • Framework revision 20e59316b8 (10 days ago), 2019-07-18 20:04:33 -0700
    • Engine revision fee001c93f
    • Dart version 2.4.0


[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /media/ZZZ/B0B8B687B8B64C1A/Dev_ubuntu/android-sdk-linux/
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • ANDROID_HOME = /media/ZZZ/B0B8B687B8B64C1A/Dev_ubuntu/android-sdk-linux/
    • Java binary at: /usr/local/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b16-5323222)
    • All Android licenses accepted.

[✓] Android Studio (version 3.4)
    • Android Studio at /usr/local/android-studio
    • Flutter plugin version 37.1.1
    • Dart plugin version 183.6270
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b16-5323222)

[✓] VS Code (version 1.36.1)
    • VS Code at /usr/share/code
    • Flutter extension version 3.2.0

[✓] Connected device (1 available)
    • Android SDK built for x86 • emulator-5554 • android-x86 • Android 5.1.1 (API 22) (emulator)

• No issues found!

我的操作系统是Ubuntu18.04,想用模拟器调试,请帮帮我

您有 3 个选择:

  1. 您可以在 Android Studio 中打开您的模拟器,然后从 VSCode.

  2. 调试您的应用程序
  3. 您还可以检查您的机器中是否安装了 adb(Android debugger bridge)。

  4. 否则您可以 运行 在真实设备中使用您的应用程序。

这个命令解决了我的问题

flutter config --android-sdk <sdk-location>

link