How to set up ADB for remote machine development and local device deployment
Solution 1:
I had a similar situation. I work on a remote desktop for development but my android device is connected to my local laptop. I wanted to be able to use adb and the android plugin in eclipse on the remote desktop and connect to the device attached to my laptop. After searching on the internet and not finding anything that really helped, I decided to write a port forwarder that would do the trick. You can find it here. I hope it will be helpful to other people as well.
Solution 2:
Beginning Android 4.3 you can:
- Make
adb
server listen on all interfaces. You have two options:- Make gListen=1 and recompile
adb
(I have compiled it on Linux-x64 machine for you and put it here) - Start adb server with
-a
parameter:adb -a -P 5037 fork-server server&
- Make gListen=1 and recompile
- Use
adb
on your remote machine with extra parameter, e.g.adb -H <remote_host> shell
Solution 3:
Another setup for remote host + local device testing. This will be useful for lots of people working from home on a laptop, connected to their development host machine still in the office. Note that I assume both devhost/laptop are both running Unix, but other OSes will be able to run the commands on the command prompt/shell.
# Kill old adb server.
devhost$ adb kill-server
# Activate adb server on client
laptop$ adb start-server
# Start ssh tunnel. Hide/minimize this window not to close it by accident
laptop$ ssh -XC -R 5037:localhost:5037 <your devhost machine>
# Should work by now with the local device connected to the laptop
devhost$ adb logcat
Solution 4:
You can solve the issue by port forwarding.
- Download Secure Shell app from the Chrome app store
- Connect to your machine (step-by-step setup)
- In this connection, disable adb server: adb kill-server
- Create a new port forwarding connection (same as a regular connection, but set the SSH Arguments field to: -N -R 5037:localhost:5037)
- On your laptop, open up a terminal and enable adb server: adb start-server
Solution 5:
My situation required using a VM that is on a different network, but that I rmd into (an Azure VM). The VM and my local laptop are both running Windows 10. First, I had to install USB Redirector RDP Edition on my local machine (costs $80, but there might be free alternatives), then install the Google Android USB driver on the VM and the Universal Adb Driver on the VM. I'm now able to load an Android Studio App the project in Android Studio on the VM, connect an Android device on my laptop, and debug the app on the device.