[英]How to use adb with emulator like Memu / Bluestacks / Nox App Player
I want to use adb
with an android emulator.我想将
adb
与 android 模拟器一起使用。 Can I fake a USB connection or how is this possible ?我可以伪造 USB 连接,或者这怎么可能?
Emulator is rooted , USB-Debugging Option is On模拟器已root , USB调试选项已打开
I also tried via apps like adbWireless but I get host has failed to respond (10060) error.我也尝试通过像 adbWireless 这样的应用程序,但我得到主机未能响应 (10060)错误。
Do I always need a USB-connection for initializing?我是否总是需要 USB 连接进行初始化? How is it possible to connect
adb
with an emulator?如何将
adb
与模拟器连接?
I'm using Memu version 2.3 and the port used to connect it to Android studio is 21503. Navigate to your sdk's platformtools directory and execute the following in cmd.If it fails try to execute it again.我使用的是 Memu 2.3 版,连接 Android studio 的端口是 21503。导航到你的 sdk 的 platformtools 目录并在 cmd 中执行以下命令。如果失败尝试再次执行它。 You can also install samsung USB driver and try again.
您也可以安装三星 USB 驱动程序并重试。
adb connect localhost:21503
I have solved by Following steps:我已经通过以下步骤解决了:
Go to Memu Installation Directory: (In My Case D:\\Program Files\\Microvirt\\MEmu)转到 Memu 安装目录:(在我的情况下 D:\\Program Files\\Microvirt\\MEmu)
And then Delete the adb.exe file.然后删除 adb.exe 文件。 It should work fine for you.
它应该适合你。
For MEmu, Droid4X and other VirtualBox-based emulators exists very simple way:对于 MEmu、Droid4X 和其他基于 VirtualBox 的模拟器,存在非常简单的方法:
You need forward 5555 port to you host.您需要将 5555 端口转发到您的主机。
For example in Droid4X you open \\vms\\droid4x\\droid4x.vbox
in text editor.例如,在 Droid4X 中,您在文本编辑器中打开
\\vms\\droid4x\\droid4x.vbox
。 It is just simple xml file.它只是一个简单的 xml 文件。
In section <NAT>
you add line:在
<NAT>
部分添加一行:
<Forwarding name="MY_PORT" proto="1" hostip="127.0.0.1" hostport="5565" guestip="10.0.2.15" guestport="5555"/>
You can use not only 5565 port.您不仅可以使用 5565 端口。 It must be uneven and from range 5555-5585 or adb do not auto find your emulator.
它必须是不均匀的,并且范围在 5555-5585 之间,否则 adb 不会自动找到您的模拟器。
Save file and start emulator.保存文件并启动模拟器。 Now run
adb devices
and you see emulator-5564
in list.现在运行
adb devices
,你会在列表中看到emulator-5564
。
You must edit file only on fully stopped emulator or you changes will be overwritten.您只能在完全停止的模拟器上编辑文件,否则您的更改将被覆盖。 It is mean stop not only virtual machine.
这不仅意味着停止虚拟机。 You must stop service process too.
您也必须停止服务进程。 Usually it called as
VBoxSVC.exe
or MemuSVC.exe
or another *SVC.exe
from folder of your emulator.通常它称为
VBoxSVC.exe
或MemuSVC.exe
或模拟器文件夹中的另一个*SVC.exe
。
For Memu you need edit \\MEmu\\MemuHyperv VMs\\MEmu\\MEmu.memu
.对于 Memu,您需要编辑
\\MEmu\\MemuHyperv VMs\\MEmu\\MEmu.memu
。 All others stay same.所有其他人保持不变。
In my case this command line didn't work for me在我的情况下,这个命令行对我不起作用
adb connect localhost:21503
Changing localhost
to 127.0.0.1
solved it将
localhost
更改为127.0.0.1
解决了它
adb connect 127.0.0.1:21503
Ok, here is a step-by-step guide for MEmu emulator.好的,这是 MEmu 模拟器的分步指南。
Download and install adbWireless app into emulator (google "adbwireless xda", I can not insert more than 2 links in this post).下载并安装 adbWireless 应用程序到模拟器(谷歌“adbwireless xda”,我不能在这篇文章中插入超过 2 个链接)。 After that, you will need to setup a network bridge, do exactly as written here, and restart your computer: MEmu bridge
之后,你需要设置一个网桥,完全按照这里写的做,然后重启你的电脑: MEmu桥
Then open emulator, activate USB debugging, run adbwireless, press the button.然后打开模拟器,激活USB调试,运行adbwireless,按下按钮。 You should see the IP adress, starting from "192.168".
您应该会看到 IP 地址,从“192.168”开始。 If it does not - you made something wrong.
如果没有 - 你做错了什么。
Run the command shell with administrator privilages.以管理员权限运行命令 shell。 Navigate with it to the folder with adb (in my case it is "D:\\Program Files\\Microvirt\\MEmuHyperv" or add this to system Path variable).
使用它导航到带有 adb 的文件夹(在我的情况下它是“D:\\Program Files\\Microvirt\\MEmuHyperv”或将其添加到系统路径变量中)。 Remebber the IP from adbwireless, then in shell ececute a command
adb connect your_ip
, in my case it was 192.168.0.101.记住来自 adbwireless 的 IP,然后在 shell ececute 命令
adb connect your_ip
,在我的情况下是 192.168.0.101。 The shell will notify you: connected to 192.168.0.101:5555
. shell 会通知你:
connected to 192.168.0.101:5555
。 Then execute adb devices
, so you should see the list of connected devices.然后执行
adb devices
,所以你应该看到连接的设备列表。 Congratulations, you are connected to MEmu using adb.恭喜,您已使用 adb 连接到 MEmu。
There are more ways to setup connection at this post , but it is in russian. 这篇文章有更多设置连接的方法,但它是俄语的。
First of all you should find configuration file of specific emulator's VM.首先你应该找到特定模拟器虚拟机的配置文件。 eg Memu's configuration vm's file is located near ~
C:\\Program Files\\Microvirt\\MEmu\\MemuHyperv VMs\\MEMU_NAME\\MEMU_NAME.memu
.例如,Memu 的配置
C:\\Program Files\\Microvirt\\MEmu\\MemuHyperv VMs\\MEMU_NAME\\MEMU_NAME.memu
文件位于 ~ C:\\Program Files\\Microvirt\\MEmu\\MemuHyperv VMs\\MEMU_NAME\\MEMU_NAME.memu
。 Secondly, as said in 1st answer, in section you add line:其次,如第一个答案所述,在部分中添加行:
<Forwarding name="ADB" proto="1" hostip="127.0.0.1" hostport="21743" guestip="10.0.2.15" guestport="5555"/>
Take the value of hostport
, here it is 21743
.取
hostport
的值,这里是21743
。
Third step is to use adb from MEmuHyperv C:\\Program Files\\Microvirt\\MEmuHyperv\\adb.exe
.第三步是使用来自 MEmuHyperv
C:\\Program Files\\Microvirt\\MEmuHyperv\\adb.exe
。 One of possible solutions for this is to open cmd, then to cd to MEmuHyperv's folder and work from there.对此可能的解决方案之一是打开 cmd,然后 cd 到 MEmuHyperv 的文件夹并从那里开始工作。
As MEmuHyperv is now separate project, you can download it from here http://www.memuplay.com/blog/2016/08/08/memuhyperv-tool/由于 MEmuHyperv 现在是单独的项目,您可以从这里下载它http://www.memuplay.com/blog/2016/08/08/memuhyperv-tool/
For Nox App Player, the port is 62001
.对于 Nox App Player,端口为
62001
。
$ adb connect 127.0.0.1:62001
connected to 127.0.0.1:62001
$ adb devices
List of devices attached
127.0.0.1:62001 device
$ adb shell
root@android:/ #
If it does not work, please turn on "USB Debugging" first:如果还是不行,请先打开“USB调试”:
Developer mode has been enabled.
开发者模式已启用。
FindEmulatorPort Used to find the android emulator adb port and automatically connect, such as Tencent mobile assistant, Netease MuMu、BlueStacks、Nox App Player and so on. FindEmulatorPort用于寻找安卓模拟器adb端口并自动连接,如腾讯手机助手、网易MuMu、BlueStacks、Nox App Player等。 download from: https://gitee.com/tp7309/TTEmulatorPortFinder/repository/archive/master.zip
下载地址: https : //gitee.com/tp7309/TTEmulatorPortFinder/repository/archive/master.zip
python emulator_port.py
copy adb.exe and all files you find in it's folder in the android SDK , used by your Studio, than past it to memu folder to replace old memu adb.复制 adb.exe 以及您在 Studio 使用的 android SDK 文件夹中找到的所有文件,然后将其传递到 memu 文件夹以替换旧的 memu adb。 that's it.
就是这样。
I am using a memu with Android 7 and after a lot of effort I realized that on this version of Android you have to change the port to 21513 ( memu version 7.2.7 / Android 7.1 )我在 Android 7 上使用 memu,经过很多努力,我意识到在这个版本的 Android 上你必须将端口更改为 21513(memu 版本 7.2.7 / Android 7.1)
adb connect 127.0.0.1:21513
I hope you find it useful我希望你觉得它有用
This method works well on Xamarin and Android Studio .此方法在Xamarin和Android Studio上运行良好。
Tested with NOX v7用NOX v7测试
adb.exe
and nox_adb.exe
.adb.exe
和nox_adb.exe
。D:\\android-sdk\\platform-tools
D:\\android-sdk\\platform-tools
adb.exe
and rename it to nox_adb.exe
.adb.exe
复制一份并将其重命名为nox_adb.exe
。 so we have both adb.exe
and nox_adb.exe
in platform-tools .adb.exe
和nox_adb.exe
。 After performing these simple steps, it is better to restart the PC.执行完这些简单的步骤后,最好重新启动 PC。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.