【问题标题】:VS code Unable to connect to Chrome debug port: 37095VS 代码无法连接到 Chrome 调试端口:37095
【发布时间】:2021-11-11 22:29:27
【问题描述】:

我通过以下方式安装了 Flutter 和 VS Code:

$ sudo snap install --classic code
$ sudo snap install --classic flutter 
$ tail -n 1 ~/.bashrc
export CHROME_EXECUTABLE="/usr/bin/chromium"
$ flutter doctor -v
[✓] Flutter (Channel stable, 2.2.1, on Linux, locale en_AU.UTF-8)
    • Flutter version 2.2.1 at /home/debian/snap/flutter/common/flutter
    • Framework revision 02c026b03c (4 months ago), 2021-05-27 12:24:44 -0700
    • Engine revision 0fdb562ac8
    • Dart version 2.13.1

[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.


[✓] Chrome - develop for the web
    • CHROME_EXECUTABLE = /usr/bin/chromium

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions).

[✓] Connected device (1 available)
    • Chrome (web) • chrome • web-javascript • Chromium 90.0.4430.212 built on Debian 11.0, running on Debian 11.0

! Doctor found issues in 2 categories.

我可以在终端启动 Flutter 应用了。

但是,在 VS 代码下我得到 Unable to connect to Chrome debug port: 37095

我错过了什么?

【问题讨论】:

    标签: flutter visual-studio-code flutter-web


    【解决方案1】:

    如果你在代理后面工作,你应该设置 env no_proxy=localhost,127.0.0.1。 但如果你没有使用任何代理,请尝试安装Dart Chrome Extension。

    【讨论】:

      【解决方案2】:

      尝试运行flutter clean,然后运行flutter create .

      如果没有解决问题,请删除 .vscode 目录中的 launch.json,然后运行您的应用,如果 vscode 中的 launch.json 文件中存在任何错误配置,则会出现此问题。并确保您的端口为空且未被任何其他程序(如 Microsoft IIS 服务或 MySQL)使用...

      要使 vscode CTRL+F5 在 chrome 或 web-server 中运行,请转到您的项目根目录创建 .vscode 目录并在该文件夹中添加 launch.json 文件。

      现在,如果您只想通过 vscode 调试器在 Web 服务器中运行,请在您的内部添加此行 launch.json

      {
       "version": "0.2.0",
       "configurations": [{
              "name": "Flutter",
              "request": "launch",
              "type": "dart",
              "args": ["-d", "web-server","--web-port", "8000"],
          }
      ]}
      

      如果您想在 chrome 设备中启动,请将参数 web-server 更改为 chome 即

      {   
       "version": "0.2.0",
       "configurations": [{
              "name": "Flutter",
              "request": "launch",
              "type": "dart",
              "args": ["-d", "chrome","--web-port", "8000"],
          }
      ]}
      

      现在运行CTRL+F5

      如果您在更改端口时没有问题,请尝试使用 flutter run -d chrome --web-port XXXXX 从终端运行您的程序

      这里的 XXXXX 代表你的端口号。

      【讨论】:

        【解决方案3】:

        解决办法是必须通过SNAP安装chromium、flutter和VS code。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2022-06-22
          • 2020-04-21
          • 2021-07-25
          • 2023-02-04
          • 2016-03-18
          • 1970-01-01
          • 2021-10-31
          • 1970-01-01
          相关资源
          最近更新 更多