I have a requirement to deploy a test application and issue commands on a device connected to another machine in the same network.
I read through http://developer.android.com/tools/help/adb.html#directingcommands but I am not able to find the answer.
I tried using adb connect <remote machine IP>
but I got unable to connect
error.
Is there a way to deploy applications and execute adb
commands on a device connected to a remote system?
From the
adb
tag wiki:adb connect
command is used to connect the localserver
with adaemon
on a network connecteddevice
. But what you want is to connect a localclient
to a remoteserver
. To achieve that you need the latestadb
version installed on both local and remote systems.Start an instance of
adb server
on the remote system (the one which you will be plugging the devices into) with this command:Now you can force
adb
on the local system to use the other (remote) server instead of starting its own (local) instance by prepending-H <REMOTE_IP> -P <PORT_NUMBER>
to youradb
commands:Alternatively setting
ANDROID_ADB_SERVER_ADDRESS=<REMOTE_IP>
andANDROID_ADB_SERVER_PORT=<PORT_NUMBER>
environment variables on the client side would let you avoid having to specify the<REMOTE_IP>
and<PORT_NUMBER>
for everyadb
command.And if omitted the
<PORT_NUMBER>
would default to5037
.Perhaps this will help:
Its a java library that I've developed few months ago specifically with that remote adb commands in mind. The basic idea was to provide some abstraction layer where devices could be similarly accessed on remote machine as it was locally connected. Check it out:
https://github.com/lesavsoftware/rem-adb-exec
PS. and it uses SSH tunnel so it should be secure enough.
What about using SSH to connect to the machine on which your device is attached and issue ADB command from there ? This is at least what we do in our company where we have dozens of devices we control like that.