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.
- Install the Android SDK (not the ADT bundle) on your Mac OS X host & start an ARM based emulator (With use Host GPU enabled)
- 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.
- Install the PuTTY SSH (putty.exe) client on the Windows Guest OS
- Ensure port 22 is open between the Windows guest OS and the Mac OS X host.
- Create a connection in PuTTY to the Host OS
- You will most likely use the 192.168.x.x IP address of the host
- Go to Connection -> SSH -> Tunnels and add a local/auto port forwarding for 5555 to locahost:5555 and 5554 to localhost:5554.
- Save and Open the connection in PuTTY
- Provide the login credentials for the Mac OS X host – anything typed in this window is executed on the remote machine
- You can check or change the tunnel settings via the icon in the upper left of the PuTTY window
- Minimize PuTTY (keep it open to maintain the SSH connection)
- 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.
- Refresh target devices in Delphi and it should appear
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!