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?
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
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.
<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
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.
I have solved by Following steps:
Go to Memu Installation Directory: (In My Case D:\Program Files\Microvirt\MEmu)
And then Delete the adb.exe file.
It should work fine for you.
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:
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.
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.
download from: https://gitee.com/tp7309/TTEmulatorPortFinder/repository/archive/master.zip
For Nox App Player, the port is
$ 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 [email protected]:/ #
If it does not work, please turn on “USB Debugging” first:
- Start Nox App Player.
- Go to “Settings” -> “About tablet”.
- Tap (click) “Build number” 7 times, until it says:
Developer mode has been enabled.
- Go back to the previous screen.
- Go to “Developer options”.
- Turn on “USB debugging”.
- Restart Nox App Player.
- How to connect Android Studio with Nox App Player for Android development and debug | NoxPlayer
- The guide from the official site. Pictures for step-by-step instructions are available.
- I found that turning on “Root”, as suggested by the guide, is not necessary.
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.
- 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.
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
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/