Search code examples
androidadb

ADB ant debug install on multiple android devices


Is there a a way to run the command 'ant debug install' when there are multiple android devices connect through ADB?

I currently have two devices connect to ADB through wifi. When I run ant debug install I get the following error ad infinitum.

 [exec] error: more than one device and emulator
     [exec] - waiting for device -
     [exec] error: protocol fault (status read)
     [exec] - waiting for device -
     [exec] error: protocol fault (status read)
     [exec] - waiting for device -
     [exec] error: protocol fault (status read)
     [exec] - waiting for device -
     [exec] error: protocol fault (status read)
     [exec] - waiting for device -
     [exec] error: protocol fault (status read)
     [exec] - waiting for device -
     [exec] error: protocol fault (status read)

If I disconnect one of the devices, it will properly run.

I also tried

ant debug install [ip of specific device]

this provided the same erroneous results.

Is there a way I can install to both devices at once?


Solution

  • The android ant build script doesn't seem to support installing to all devices in one command. However, the install target does take an ant property called ${adb.device.arg}. You should at least be able to control to which device you want the app to get installed on from the command line, like so:

    ant -Dadb.device.arg="-s <deviceid>" debug install
    

    Now, if you can use one of the scripts described in here to retrieve a list of all connected device ids, you should be able to write a simple script to iterate the ant install command for each device.

    Btw, if you are interested, the ant build xml file is included as part of the sdk and located in your sdk folder:

    $ANDROID_SDK/tools/ant/build.xml