I don't have a second machine with the SDK to hand, but I note that the emulator's listen ports (default 5554, 5555) are listening on 0.0.0.0, i.e. reachable from remote machines, and that adb --help shows a connect <host>:<port> command. I assume that would make it show up in adb devices so adb commands work on it. For Eclipse, try "Run / Run Configurations..." and set the Target to Manual. That gives you a "device chooser" which I'm guessing would include a remote emulator if adb is connected to it. Worth a try.
I haven't previously tried (or even noticed) the adb connect command that cmb mentioned, but I can confirm that forwarding the TCP ports yourself — such as over SSH — works fine.
The emulator listens on two TCP ports per instance: 5554 for the telnet interface and 5555 for control communication with tools like DDMS. So you could probably get away with only forwarding port 5555 (though I've only tried it so far with both). Each subsequent emulator takes the next available even+odd port number tuple (up to around 5580, I think).
For reference, I did the following steps on my local machine:
Here is how I solved it on Windows. I pretty much followed Christopher's lead, but I can't edit, so a new answer will have to do.
The problem I had was that ADB as well as the emulator was just listening on 127.0.0.1, not 0.0.0.0, for me. Otherwise I would have used TCPMon. I guess this is either different on Windows, or has changed with the latest versions of the SDK. (You can check with netstat -ban.)
I installed WinSSHD on the machine that runs the emulator. (I believe it should work with freeSSHd as well, but I couldn't get a login working there.)
I opened port 22 (TCP) in the Windows Firewall. (WinSSHD might be able to do that for you.)
I created a virtual account in the WinSSHD GUI.
I created a new PuTTY connection from the development machine to the emulator machine and made sure I could connect.
Then I set up tunnelling in PuTTY: Connection -> SSH -> Tunnels
(Connect and keep PuTTY open, to maintain the tunnel.)
Now I fired up the emulator on the remote machine and made sure that ADB is not running there.
I restarted ADB on the development machine (adb kill-server, then adb start-server).
adb devices and the remote emulator showed up as emulator-5554 device. I could now deploy and run my app straight from Eclipse/ADT, where the emulator showed up under Virtual Devices as if it was a local emulator.
I realize this question is really old, but I solved the problem slightly differently, and it took me a while to figure out this trivial solution.
I usually use a Windows7 PC or laptop (depending on where I'm working) as my front-end because I like the GUI, however I prefer to do all of my edit/compile/debug on a headless Ubuntu server because of all the command-line power it provides. My goal is to make each windows system as much of a thin-client as possible without any extra services (such as sshd) or firewall holes.
So here is the senario:
System-A: Windows7 system with android emulator running
System-B: Ubuntu server with SDK installed
The problem as described earlier is that the emulator on System-A binds to localhost, not the external ethernet interface, so adb on the System-B cannot access the emulator on System-A. All you need to do is set up remote port forwarding in PuTTY for your SSH connection to System-B. The trick is to check the "Remote" radio button when you create the two tunnels so that the tunnel direction is reversed (tunneling from the server you are logging into to the client you are logging in from).
Finally, connect with adb to "localhost" on System-B after establishing the SSH connection:
System-B$ adb connect localhost
connected to localhost:5555
System-B$ adb devices
List of devices attached
localhost:5555 device
Now you can download images/debug as normal, and it is a trivial matter to switch to a different Windows system if you want to take your laptop out and get some coffee.
In addition, by also tunneling port 5037 in the same manner you can actually forward your adb server connection so that you can connect a real android device over USB on System-A, and download images to it from System-B. In order for this to work, you need to make sure that the adb server is running on System-A, and not running on System-B before starting your SSH session:
First, start the adb server on System-A (command prompt)
C:\> adb start-server
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
C:\> adb devices
List of devices attached
3435F6E6035B00EC device
Next, kill the adb server on System-B
System-B$ adb kill-server
Finally, restart your ssh session to System-B and verify
System-B$ adb devices
List of devices attached
3435F6E6035B00EC device
I found an easy way to do this if your two machines are in the same private network and therefore do not need to use SSH encryption (which is the common case). This may help as an SSH tunnel can be quite long and difficult to install. For example, installing an SSH daemon under Cygwin / Windows for the first time may lead to give up (well, I gave up).
Under Windows, what follows requires having Cygwin installed with the package httptunnel. This must work under Linux / httptunnel as well but I didn't try.
Run the emulator on one of the machines (let's say its host name is HostEmulator)
Start Eclipse on the other machine (let's call it HostEclipse)
Open a Cygwin terminal on each machine, and then,
On HostEmulator, enter the following cygwin commands:
These two commands create two half-bridge that listen to the ports 10001 and 10001 and that redirect the I/O of these ports to the local ports 5554 and 5555, which are the ports used by the emulator (actually, the first lauched emulator - if you are several of them running they will use higher port numbers as seen in other replies of this page).
These commands create the missing half-bridges. They listen to the local ports 5554 and 5555 and redirects the I/O of these ports to the half-bridges we have created on HostEmulator just before.
Then, still on HostEclipse, enter these three commands:
adb kill-server
adb start-server
adb devices
This restarts adb as it doesn't detect the remote emulator otherwise. It must be doing some scanning at startup. And then it lists the devices (the available emulators) just for checking.
And there you go.
You can work with your remote emulator as if it was local.
You have to keep the Cygwin terminals open on both machine otherwise you would kill the half bridges you created.
I used the port 10000 and 10001 for the machine/machine exchanges here, but of course you can use other ports as long as they are not already in use.
My solution for windows + AndroVM (which requires a host-only adapter) when my ssh service failed to start. so it doesn't require any additional software.
None of the proposed solutions worked for me.
I've started from Emirikol's solution and refined it, as with the new Android API > 21 the emulator was appearing offline and I had to go to Genymotion settings and leave Android SDK path empty.
And from command line:
When you run adb, it starts a server copy of itself if one isn't already running.
You can start that copy yourself on the machine with the device and since sdk 4.3 you can give it the -a option to tell that server to listen for remote machines. Do that with the following command which doesn't exit:
adb -a -P 5037 server nodaemon
On the machine you want to use the device from, set ADB_SERVER_SOCKET to tcp:xxxx:5037 in an environment variable (or give the same value to each adb invocation with the -L option), where xxxx is the IP address or hostname of the machine with the devices, and 5037 matches the port you gave the in the command above.
We use this to give access to about 100 emulators spread over 3 machines to a machine running end to end tests in parallel, and to developers wanting to share real devices remotely.
You can forward ports to and from the emulator with adb forward and adb reverse, and they'll appear on the machine with the devices (not the machine you're running 'adb forward' from).
Android emulators by default listens on local port 5555, so one way to connect to a remote emulator is by using a port forwarding tool to forward all LAN packets to local 5555 port.
Above command will forward 5554 and 5555 ports of PC_AS to the same ports on PC_EM. So the emulators running on PC_EM can be detected on the PC_AS.
dhaval@192.168.0.104 is the address of the PC_EM. Format of the address is username@local_ip_address
Once you run above command, the terminal window will not show anything if the command is executed successfully. It will look like nothing is going on but the process is running there.
| 💡 Note: Do not close this terminal until you want to stop remote debugging.
Step 2:
Now open another terminal window on PC_AS and run following commands one by one.
This command will stop the adb and stop the server.
This command will start the adb server.
This command will list down all the connected adb devices.
Once you run above commands, you will see that emulators of PC_EM are now detected in the PC_AS. Now you can run the projects on those emulators and debug remotely.
| 💡 Note: While doing the above process, emulators can show a dialog to trust the incoming request.
client$ adb kill-server # I observe first it kills client adb
client$ adb kill-server # then it kills server adb, do it maybe once more
client$ adb devices # show devices on server now