Use android emulator running on a different machine for debugging

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).

Run the avd using emulator or android studio (AS) on the remote machine where only emulator and avd is needed. AS is only optional

./emulator -avd avd-name -accel on -gpu on

Run the below command on the machine where you have android studio and you are coding and debugging. Before this command,

ssh -NL 5554:localhost:5554 -L 5555:localhost:5555 myuser@remote-serverCode language: CSS (css)

Then kill the local adb-server , so that it restarts and starts to see open ports 5554 and 5555 on local host and assume that this is a local emulator. After that you can list adb devices to see if new emulator is visible, otherwise AS will itself show the new devices in the devices section of the IDE

adb kill-server<code>killall adb</code><code>adb device</code>Code language: HTML, XML (xml)

I believe the emulator tries to notify a local adb server at startup; hence the need to restart adb in order for it to probe the local 5554+ ports.

Note that the localhost in the ssh command refers to the local interface of the remote machine.

adb devices showed a new emulator — emulator-5554 — and I could use it as if it were running on my local machine

References

https://stackoverflow.com/questions/1754162/remote-debugging-with-android-emulator

Mounting a remote machine’s directory on your local machine using sshfs

Recently I purchased a hosting plan from a hosting provider, had to pay them a lot of money. The give alot of free disk space on their server. I can acess the remote server using nPanel but I have to login to the hosting provider first and then open a couple of links to get the nPanel and I can use the file manager provided by the hosting service to upload files. But that’s very inconvenient.

The other way to access the server folders is to use ssh and manipulate my data on the server. I can also use rsync on my local linux machine to push the data on the remote server or vice-versa.

There is another way using sshfs using this we can mount a remote directory on our local machine like this. For example I can mount my raspberry pi on a local folder like this

sshfs pi@192.168.18.10: pi_remote/
or 
sshfs pi@192.168.18.10:public_html  pi_remote/
or
sshfs -p 21098 pi@192.168.18.10:public_html pi_remote/
to unmount use
umount pi_remote/  // to unmount the directory
Code language: JavaScript (javascript)