简体   繁体   English

将 Bluestacks 连接到 Android Studio

[英]Connect Bluestacks to Android Studio

I have recently shifted to android studio.我最近转移到 android 工作室。 I would like to know how I can test my apps in Bluestacks app player.我想知道如何在 Bluestacks 应用程序播放器中测试我的应用程序。 I had already had the bluestacks connected and working with eclipse using adb connect localhost:5555 but it doesn't seem to work with android studio.我已经使用adb connect localhost:5555了 bluestacks 并与 eclipse 一起工作,但它似乎不适用于 android 工作室。 Didn't find any help anywhere.没有在任何地方找到任何帮助。 If anyone has done this, please help.如果有人这样做过,请帮忙。

Steps to connect Blue Stack with Android Studio将 Blue Stack 与 Android Studio 连接的步骤

  1. Close Android Studio.关闭 Android Studio。
  2. Go to adb.exe location (default location: %LocalAppData%\\Android\\sdk\\platform-tools )转到adb.exe位置(默认位置: %LocalAppData%\\Android\\sdk\\platform-tools
  3. Run adb connect localhost:5555 from this location.从此位置运行adb connect localhost:5555
  4. Start Android Studio and you will get Blue Stack as emulator when you run your app.启动 Android Studio,当您运行您的应用程序时,您将获得 Blue Stack 作为模拟器。

In my case I didn't needed start adb.exe.就我而言,我不需要启动 adb.exe。 I only started the BlueStacks before android studio.我只android studio之前开始使用 BlueStacks。

After that when I press "Run" in android studio, bluestacks is detected as a new emulator.之后,当我在 android studio 中按“运行”时,bluestacks 被检测为新的模拟器。

在此处输入图片说明

在此处输入图片说明

Regards.问候。

I Solved it.我解决了。 I just had to add the path of android studio's platform-tools after removing my earlier eclipse's path.在删除我之前的 eclipse 路径后,我只需要添加 android studio 的平台工具的路径。 I don't know, maybe some conflict in the command.我不知道,也许命令中有些冲突。

world !世界 !

No need to do execute batch command.无需执行批处理命令。 With the current version, just run BLUESTACKS before ANDROID STUDIO使用当前版本,只需在 ANDROID STUDIO 之前运行 BLUESTACKS

In my case, none of the above approaches worked for me till I had to enable an Android DEBUG Bridge Option under the BlueStack emulator.就我而言,在我必须在 BlueStack 模拟器下启用 Android DEBUG Bridge Option 之前,上述方法均不适合我。 Check the picture below.检查下面的图片。

An approach inspired from : Vlad Voytenko灵感来自: Vlad Voytenko 的方法

在此处输入图片说明

I Hope It's Helps Someone!我希望它可以帮助某人!

For those people with (cannot connect to localhost:5555: No connection could be made because the target machine actively refused it. (10061) :对于那些有(cannot connect to localhost:5555: No connection could be made because the target machine actively refused it. (10061)

Blustacks is listening at IPv4-Localhost-TCP-5555 (not IPv6). Blustacks 正在侦听IPv4-Localhost-TCP-5555 (不是 IPv6)。 Most of the time Windows has IPv6 enabled by default and Localhost is solving ::1:大多数情况下,Windows 默认启用 IPv6,Localhost 正在解决::1:

If the client (ADB) tries to connect a server using localhost and IPv6 is enabled on the main network adapter, ADB will not connect to the server.如果客户端 (ADB) 尝试使用 localhost 连接服务器并且主网络适配器上启用了 IPv6,ADB 将不会连接到服务器。

So, you have two options :所以,你有两个选择:

1- Change your ADB client TCP connection string to localhost IPV4 : adb connect 127.0.0.1 1- 将您的 ADB 客户端 TCP 连接字符串更改为 localhost IPV4: adb connect 127.0.0.1

OR :或者 :

2-Disable IPV6 protocol from the main network adapter. 2-从主网络适配器禁用 IPV6 协议。

first open bluestacks and go to settings > preferences > check the Enable Android Debug Bridge (ADB) and press Change path button, then select adb path.首先打开bluestacks并转到设置>首选项>选中启用Android调试桥(ADB)并按更改路径按钮,然后选择adb路径。 (default location: %LocalAppData%\\Android\\sdk\\platform-tools)

then install one apk in emulator (by click the installed apps > install apk in bluestacks home screen)然后在模拟器中安装一个 apk(通过单击已安装的应用程序 > 在 bluestacks 主屏幕中安装 apk)

after doing this works run cmd by administrator and got to adb path then run this command:完成此工作后,由管理员运行 cmd 并进入 adb 路径,然后运行以下命令:

adb connect localhost:5555

now you can open VSCodde or AndroidStudio and select BlueStacks emulator.现在您可以打开 VSCodde 或 AndroidStudio 并选择 BlueStacks 模拟器。

These are all old answers, nothing works for me till I finally come out with a solution of my own.这些都是旧答案,在我最终提出自己的解决方案之前,对我没有任何用处。 for a much later version (I'm using the 5.6x version, latest at the time of posting), just go to Settings in bluestack, click advanced, toggle on DB and run adb connect localhost:[port] with port being the number shown in the ADB information page (the one I underlined).对于更高版本(我使用的是 5.6x 版本,发布时最新版本),只需 go 到 bluestack 中的设置,单击高级,切换 DB 并运行 adb connect localhost:[port],端口为数字显示在亚行信息页面(我加下划线的那个)。 Voila, you should automatically see another mobile device available on the Android Studio瞧,您应该会自动在 Android Studio 上看到另一个可用的移动设备在此处输入图像描述

  1. Goto Blustacks settings > Preferences > Check Enable Android Debug Bridge (ADB)转到 Blustacks 设置 > 首选项 > 选中启用 Android 调试桥 (ADB)
  2. Restart Bluestacks and Start Android Studio重启 Bluestacks 并启动 Android Studio
  3. Done完毕

You can easily use it in Bluestacks 5 by going to:您可以通过以下方式轻松地在Bluestacks 5 中使用它:

  1. Settings设置
  2. Advanced先进的
  3. Enable Android Debug Bridge启用 Android 调试桥

蓝叠

note number port in bluestack settings device bluestack 设置设备中的注释编号端口

ex here: adb connect localhost:55094例如: adb connect localhost:55094

在此处输入图像描述

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

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