简体   繁体   English

如何将 VS Code 中的 Flutter 与 BlueStacks 4 模拟器连接起来?

[英]How can I connect Flutter in VS Code with the BlueStacks 4 emulator?

How can I connect Flutter with VS Code to emulator BlueStacks 4. I do not want to use Android Studio because it is bad software.如何将 Flutter 与 VS Code 连接到模拟器 BlueStacks 4。我不想使用 Android Studio,因为它是糟糕的软件。 Can someone help me please?有人能帮助我吗?

For this we need to establish ADB(Android Debug Bridge) connection between VScode and Android Emulator(Bluestacks) which has PID(Process identifier) 5555为此,我们需要在 VScode 和具有 PID(进程标识符)5555 的 Android 模拟器(Bluestacks)之间建立 ADB(Android 调试桥)连接

For time save first check, status bar of VScode to check device connection.为了节省时间首先检查,VScode的状态栏检查设备连接。 Two case possible show below :两种情况可能显示如下:
在此处输入图像描述

在此处输入图像描述

If you are fall under 2nd case so it is good to go with debugging.如果您属于第二种情况,那么最好进行调试。 And no need look at other points.并且不需要看其他点。

In all other case let's establish connection.在所有其他情况下,让我们建立连接。 Steps are步骤是

  1. Open Bluestacks and go to settings by clicking on like icon.打开 Bluestacks 并通过单击 like 图标进入设置。 在此处输入图像描述
  2. Then move to preferences and then scroll down and turn on Abd connection然后移动到首选项,然后向下滚动并打开 Abd 连接
  3. In terminal type adb connect localhost:5555在终端类型adb connect localhost:5555 在此处输入图像描述
  4. Now check again status bar in VScode.现在再次检查 VScode 中的状态栏。 Status of devices will be present将显示设备状态

Yes, you can do it.是的,你可以做到。 Just open bluestacks and go to settings.只需打开 bluestacks 并转到设置。 Then go to preferences and tick the checkbox just beside the option enable Android Debug Bridge(ADB).然后转到首选项并勾选启用Android Debug Bridge(ADB)选项旁边的复选框。 Then if you open Visual Studio Code and search for devices you will find bluestacks android emulator in the list of devices.然后,如果您打开 Visual Studio Code 并搜索设备,您将在设备列表中找到 bluestacks android 模拟器。

Hope it helps...希望能帮助到你...

step 1: go to setting button on bluestack enter image description here第 1 步:转到 bluestack 上的设置按钮 在此处输入图像描述

step 2: then go to the advance and ensure that ADB is turn on enter image description here第 2 步:然后转到高级并确保打开 ADB 在此处输入图像描述

step 3: after that, you must to restart your bluestacks, then open a terminal and go to your Android SDK folder: ../Android/Sdk/platform-tools/ and copy this path enter image description here第 3 步:之后,您必须重新启动 bluestacks,然后打开终端并转到您的 Android SDK 文件夹:../Android/Sdk/platform-tools/ 并复制此路径在此处输入图像描述

step 4: Now change the directory by cd with this path and run this command: adb connect localhost:5555 if this command is not working then use this command : .\adb connect localhost:5555 enter image description here第 4 步:现在通过 cd 使用此路径更改目录并运行此命令: adb connect localhost:5555如果此命令不起作用,则使用此命令: .\adb connect localhost:5555在此处输入图像描述

step 5: Now choose the device and run your project.第 5 步:现在选择设备并运行您的项目。 It may take some times so keep patient for that.这可能需要一些时间,所以请耐心等待。 enter image description here在此处输入图像描述

The VS Code extension uses the flutter devices command to find devices. VS Code 扩展使用flutter devices命令来查找设备。 This is turn uses adb devices .这轮到使用adb devices In order for emulators to be usable in VS Code you should make sure that a) it shows up in adb devices and b) Flutter is able to find your Android SDK (the best way to check if this is the case is running the Flutter: Run Flutter Doctor command from the VS Code command palette, which will run doctor with the same environment that VS Code has).为了让模拟器在 VS Code 中可用,您应该确保 a) 它显示在adb devices中并且 b) Flutter 能够找到您的 Android SDK(检查是否是这种情况的最佳方法是运行Flutter: Run Flutter Doctor从 VS Code 命令面板Flutter: Run Flutter Doctor命令,它将在与 VS Code 相同的环境下运行doctor )。

You have to enable adb on BlueStacks Configs.您必须在 BlueStacks 配置上启用adb It is on Right upper side Gear, Config / Advanced / enable adb它在右上方齿轮, Config / Advanced / enable adb

Hope You can use it.希望你可以使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM