Flutter 在 Windows 10 上找不到名称或 ID 与 'chrome' 匹配的设备

Flutter No devices found with name or id matching 'chrome' on Windows 10

我使用 official guide 安装了 Flutter beta 版本。 已启用的网站:

 flutter channel beta
 flutter upgrade
 flutter config --enable-web

结果是:

Setting "enable-web" value to "true".

You may need to restart any open editors for them to read new settings.

flutter devices命令的结果:

>flutter devices
1 connected device:

Web Server • web-server • web-javascript • Flutter Tools

官方指南指出应该有两个设备:

Chrome     • chrome     • web-javascript • Google Chrome 78.0.3904.108
Web Server • web-server • web-javascript • Flutter Tools

我根据官方指南创建了示例应用程序并尝试构建它:

 flutter create myapp
 cd myapp
 flutter run -d chrome

结果是:

No devices found with name or id matching 'chrome'

已安装最新 Google Chrome。我读过 on github 这个问题可以通过设置环境变量 CHROME_EXECUTABLE 来解决。我尝试使用 chrome.exe 的路径和包含 chrome.exe 的文件夹的路径来设置它,但结果相同。

我执行了flutter doctor -v:

[X] Chrome - develop for the web (Cannot find chrome executable at "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe")
    ! "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" is not executable.

我认为问题可能出在带空格的路径中,但在 CHROME_EXECUTABLE 中设置不同的路径并不能解决问题。

[X] Chrome - develop for the web (Cannot find chrome executable at "D:\Portable\Chromium\chrome-win\chrome.exe")
    ! "D:\Portable\Chromium\chrome-win\chrome.exe" is not executable.

有人知道吗?

你试过切换到主频道吗?或者到项目根目录中的 运行 "flutter create ." ?

如果不行,你可以试试:

flutter channel master
flutter upgrade
flutter config --enable-web
cd <into project directory>
flutter create .
flutter run -d chrome

As OP suggested I am listing my comments from above, as an answer. I believe the portable chrome usage is new w.r.t flutter and suspect this could be useful for others instead of deleting the question.

您可以在 Windows 10 中尝试的一些选项是。

  1. 运行 命令提示符中的 refreshenv 命令。
  2. 确保在您的路径中安装了正确的 flutter。
  3. 删除路径字符串周围的双引号 " "

在这种情况下,第三个选项解决了问题。

这个解决方案对我有用:

$ flutter upgrade
$ flutter config --enable-web
$ flutter run -d chrome

如果 chrome 在 Flutter device selection 中不可用,请尝试重新启动 IDE。

为用户和系统创建系统环境变量 变量名称:chrome 变量路径:path_to_chrome

事实证明这可以通过切换频道来解决

flutter channel
flutter channel beta