Android Debugging Mobile

Debugging Against a Remote Android Emulator

The Android emulator is impossibly slow when running inside a virtual machine. It is possible to debug against a remote emulator via SSH. Here are the steps to connect from a Windows guest OS to an OS X host OS (they can be easily adapted for a Windows host). It does require installing the Android SDK on the host OS and creating and running an emulator there. It seems to work even if you have a device connected too. I’ve gotten them both to show up in the IDE and am able to pick between them and deploy and run on the emulator.  The Emulator is still slower than hardware, but this makes it usable.

Of note, this emulator performance isn’t an issue with Delphi, but is an issue with the Android emulator. So you may find this tip useful with other Android development tools as well.

This could be adapted to debug against a remote Android Emulator running on a remote machine located anywhere on the internet. Just requires port 22 to be open between the two machines.

Thanks to hheimbuerger for the the Stack Overflow answer that got me pointed in the right direction. This information has been adapted to the DocWiki too with additional links to more information.

  1. Install the Android SDK (not the ADT bundle) on your Mac OS X host & start an ARM based emulator (With use Host GPU enabled)
  2. Enable SSH on the host
    • On a Mac OS X Host go to System Preferences -> Sharing -> Remote Login
    • On a Windows host, you need to install a 3rd party SSH host. FreeSSHd has been found to work.
  3. Install the PuTTY SSH (putty.exe) client on the Windows Guest OS
  4. Ensure port 22 is open between the Windows guest OS and the Mac OS X host.
  5. Create a connection in PuTTY to the Host OS
    1. You will most likely use the 192.168.x.x IP address of the host
    2. Go to Connection -> SSH -> Tunnels and add a local/auto port forwarding for 5555 to locahost:5555 and 5554 to localhost:5554.
  6. Save and Open the connection in PuTTY
  7. Provide the login credentials for the Mac OS X host – anything typed in this window is executed on the remote machine
  8. You can check or change the tunnel settings via the icon in the upper left of the PuTTY window
  9. Minimize PuTTY (keep it open to maintain the SSH connection)
  10. Open a new command window in the Windows guest OS and type “adb kill-server & adb devices” and you should see the emulator-5554 as a listed device.
  11. Refresh target devices in Delphi and it should appear

PuTTY Tunnels

This should work for any emulators or devices connected to the remote machine. Unlike emulators that are local, you need to start the emulators before Delphi will see them. You may need to adjust the tunnel port numbers if you are connecting multiple devices.

Good luck, and happy debugging!

28 replies on “Debugging Against a Remote Android Emulator”

That’s a good solution for Win32 boxes too. I always run into troubles when starting realistic emulator images. For simplicity reasons I switched to Linux but agreed. You kill two birds with one stone (you should not kill birds, but I hope that’s the right translation).

I have made every step but the adb devices command on the developper machine doesn’t show my emulator started on the remote machine

infos : my remote machine is a Win7 64, my developper machine is the same but on a virtualbox I use freesshd on my remote machine and putty on my developper machine (with 5555 5554 fowarded) my 4.2.2 emulator is started and the command adb devices on my remote machine work perfectly. (i kill it before i test on my developper machine) My two windows firewall are off.

Where i have made a mistake? Have you any idea what i do wrong?

Thank’s for your help Nicolas.

@Nicolas You need to enable tunneling in FreeSSHd. There is a little more setup for FreeSSHd. Browse through the settings which you can access from the Systray icon.


My issue is about the steps to connect from an Mac OS X host OS to a Windows server 2012 guest OS with VirtualBox and freeSSHd.

I obtain invariably the following message : ” ssh: connect to host port 22: Operation timed out”.

In VirtualBox, I use a second network interface card “vboxnet0” (a host-only adapter with IP My first adapter is a NAT.

With puTTY in localhost, I obtain a connection but I fail between the Windows server 2012 Guest OS and the OS X Mountain Lion Host OS. Why ?

Thanks in advance.


@Valorisa: Why do you have two network cards? It sounds like you may be trying to connect via two different networks. You will need to make sure your networking allows connections from the guest to the host. Maybe try a ping. Until you have the networking ironed out the rest won’t work.

Also, if you have a Mac OS X host you don’t need freeSSHd. Enable SSH on Mac OS X following the instructions.

Hello Jim and thanks for your fast response.
I can ping to the Windows Server Guest OS 2012 from the Mac OS X host OS but not the contrary. I could connect via (puTTY) SSH from Windows Server 2012 to MAC OS X. It’s a good idea. SSH is already enabled on MAC OS X.
I thought that the host-only adapter was needed for ssh connection between a guest and a host OS but if NAT adapter is enough, then I’ll remove the host-only adapter.

@Valorisa: You can try some different configurations with the adapter. So are you trying to connect the opposite direction from the steps I provided?

Thanks Jim,
I have tried to connect from my Windows Server 2012 guest OS (with puTTY) to Mac OS X host OS and it works very nice, but Mac OS X to Windows Server 2012 doesn’t work. No logical explanation for me. Weird !

Hi Jim,
To start with thanks for all the tutorial videos and post it has been a very helpful. I have followed every step by step. But still my development virtual machine failed to recognize my host machine.I have also enabled tunneling as u have suggested in one of the reply. Could you please make a post for those who are having both host and VM as windows operating system.


i can connect, and use…whatever it’s ok. BUT when i go list my device…is not listing D: I already marked all options on tunneling in freesshd. Please help me!
I’m use Vbox with Win 7, both are x64.

Hi Jim!
I wonder if you can help me…
I just installed XE5 and everything works. I got on the same problem that the SDK emulator is impossible slow. I am using XE5 on a VirtualBox VM.

I have an AndroVM installed on VirtualBox. I was thinking on use it, since it supposelly accept native code (it is using houdini).

However I could not find how to do that. Your article is about using SDK emulator on another machine (or the host machine) and other articles are about using a connected USB cable to XE5.

On this case is something else I dont know…


Just came back to this post … Think I’ve done everything mentioned here, sadly I can’t seem to get it working in Delphi XE8. I installed Android Developer Studio since that was the option offered, and got everything up and running. But when listing devices in the command prompt, it says

emulator-5554 offline

When running form delphi XE8, it seems to be hanging on ‘Installing…’, as if it knows the emulator is there, but can’t really reach it.

I also tried by downloading the android SDK separately, but with same results. Any suggestions ?

Finally got it working:
– Checked same version of SDK and adb are used on OS X and Windows
– in Windows VM SSH connection open with putty
– restarted device on OS X with “wipe user data” ( I do this always )
– switch “USB Debugging” on (ok, have to do this on every start if “wipe user data” is used)
– in Windows 10 VM “adb kill-server”, “adb start-server” then the device shows as accessible
– installing / debugging apps is working

Had the same problem using XE10 Berlin, where everything is secured and connected, but my Bluestacks was not listed in Delphi IDE. So I did the following:
a – adb kill-server
b – adb tcpip 5555
c – adb connect
d – adb devices
then the listed device was :5555 finally listed
Then I’ve refreshed the Target node under Android in Delphi IDE and finally a new one poped there with Bluestacks listed directly as name.
And I can finally develop my projects in the development machines and run the tests on the dedicated machine where the emulator (Bluestacks in my case) resides.
Thank for this article.

my tagging got removed, corrected version below with different tagging:

c – adb connect [remote machine IP where Bluestacks was running]
d – adb devices
then the listed device was [IP with Bluestacks]:5555 finally listed

Comments are closed.