How to use adb with emulator like Memu / Bluestack

2019-01-23 19:12发布

I want to use adb with an android emulator. Can I fake a USB connection or how is this possible ?

Emulator is rooted, USB-Debugging Option is On

I also tried via apps like adbWireless but I get host has failed to respond (10060) error.

Do I always need a USB-connection for initializing? How is it possible to connect adb with an emulator?

9条回答
SAY GOODBYE
2楼-- · 2019-01-23 19:36

For MEmu, Droid4X and other VirtualBox-based emulators exists very simple way:

You need forward 5555 port to you host.

For example in Droid4X you open \vms\droid4x\droid4x.vbox in text editor. It is just simple xml file.

In section <NAT> you add line:

<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. It must be uneven and from range 5555-5585 or adb do not auto find your emulator.

Save file and start emulator. Now run adb devices and you see emulator-5564 in list.

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.

For Memu you need edit \MEmu\MemuHyperv VMs\MEmu\MEmu.memu. All others stay same.

查看更多
兄弟一词,经得起流年.
3楼-- · 2019-01-23 19:37

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. that's it.

查看更多
家丑人穷心不美
4楼-- · 2019-01-23 19:37

First of all you should find configuration file of specific emulator's VM. e.g. Memu's configuration vm's file is located near ~ 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.

Third step is to use adb from 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.

As MEmuHyperv is now separate project, you can download it from here http://www.memuplay.com/blog/2016/08/08/memuhyperv-tool/

查看更多
成全新的幸福
5楼-- · 2019-01-23 19:38
  • Download/unzip MEmu HyperV Tool
  • Move files inside the extracted folder to: %PROGRAMFILES%\Microvirt\MemuHyperV
  • Install a host only networking adapter using driver 'MEmuNetFit.inf' in above folder Start > Control Panel > Device Manager > Network Adapters > [menu at the top of window] > Action > Install Legacy Hardware > Next > [o] Install Hardware I manually - select from a list > Next > [x] Network adapters > Have Disk > Browse... > %PROGRAMFILES%\Microvirt\MEmuHyperV\MEmuNetFit.inf
  • Bridge the network adapters Start > Control Panel > Network and Sharing Center > [links on the left side of the window] > Change adapter settings > [click host only adapter and your main internet one while holding ctrl and right click] > bridge connections
  • Close VM and open 'MEmuHyperV.exe' in the 'MEmuHyperV' folder. We're going to be connecting the VM to the adapter we created in the following steps.
  • [Right-Click the VM] > Settings > Network > Adapter 2 Removing adapter #1 breaks the VM
  • Enable adapter, select connected to 'Host-Only Adapter' and select Name: 'MEmuHyperV Host-Only Ethernet Adapter'
  • Apply settings and close MEmuHyperV
  • navigate to C:\Program Files\Microvirt\MEmu\adb.exe and launch command fro there.
  • Run adb connect 127.0.0.1:21503.
查看更多
够拽才男人
6楼-- · 2019-01-23 19:39

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. You can also install samsung USB driver and try again.

adb connect localhost:21503
查看更多
甜甜的少女心
7楼-- · 2019-01-23 19:44

Ok, here is a step-by-step guide for MEmu emulator.

Download and install adbWireless app into emulator (google "adbwireless xda", I can not insert more than 2 links in this post). After that, you will need to setup a network bridge, do exactly as written here, and restart your computer: MEmu bridge

Then open emulator, activate USB debugging, run adbwireless, press the button. You should see the IP adress, starting from "192.168". If it does not - you made something wrong.

Run the command shell with administrator privilages. 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). Remebber the IP from adbwireless, then in shell ececute a command adb connect your_ip, in my case it was 192.168.0.101. The shell will notify you: connected to 192.168.0.101:5555. Then execute adb devices, so you should see the list of connected devices. Congratulations, you are connected to MEmu using adb.

There are more ways to setup connection at this post, but it is in russian.

查看更多
登录 后发表回答