Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set up ADB for remote machine development and local device deployment

My scenario is this: I telework from home and log into my work machine via Windows Remote Desktop. I use Eclipse as my development environment for Android apps on my work computer.

Using ADB, I would like to be able to deploy apps from my work computer to a device on my home network, for scenarios where the emulator doesn't do the app justice.

I found this post, which discuss a very similar scenario, with the exception of deploying to an emulator running on a local PC, instead of deploying to a local device:

http://www.41post.com/5003/programming/android-adb-remote-emulator-access

I'm trying to take the same steps, but figure out how to target a local device on my home WiFi network & tethered to my local home PC, instead of the local emulator.

Right now, I have the remote PC set up to try and connect to my public router IP on port 5585 - but in my router, what IP/port do I forward this to to connect to the local device?

In the example using the emulator, they forward to the local PC address where the emulator is running and port 5555, and adb is not running on the local PC. I have configured my router to forward to my device IP, with the device on WiFi, as well as my local PC IP where the device is tethered.

However in both scenarios, when I try adb connect <routerIP>:5585 on my remote PC, it gives me an error unable to connect to <routerIP>:5585:5585. I get the same response when trying to forward to/listen to other ports. I'm not getting any security errors in the router log, so it appears the port forwarding is working.

Questions:

  • What local IP/port number should I forward to when configuring port forwarding on my local network to connect to the local device using the remote adb instance?
  • Should I be targeting the local PC IP that the device is tethered to, or the local device IP?
  • If I target the local device IP, what port number should I forward to?
  • Do I need adb running on my local PC?
like image 303
Sean Barbeau Avatar asked Nov 07 '12 21:11

Sean Barbeau


People also ask

How do I enable adb remotely?

Type adb tcpip 5555 in the command line or Terminal and press Enter. Find your phone's IP address in Settings > About Phone > Status > IP Address. Back in the command line or Terminal, type adb connect [your Android's IP address]. Finally, press Enter again.

How do I use adb on Android?

To use ADB with your Android device, you must enable a feature called “USB Debugging.” Open your phone's app drawer, tap the Settings icon, and select “About Phone”. Scroll all the way down and tap the “Build Number” item seven times. You should get a message saying you are now a developer.


3 Answers

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.

like image 189
Guy Chauliac Avatar answered Oct 21 '22 21:10

Guy Chauliac


Beginning Android 4.3 you can:

  1. 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&
  2. Use adb on your remote machine with extra parameter, e.g. adb -H <remote_host> shell
like image 33
Roman Saveljev Avatar answered Oct 21 '22 22:10

Roman Saveljev


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 
like image 10
Jindor Avatar answered Oct 21 '22 21:10

Jindor