ADB ant debug 安装在多个 android 设备上

ADB ant debug install on multiple android devices

当有多个 android 设备通过 ADB 连接时,是否有办法 运行 命令 'ant debug install'?

我目前有两台设备通过 wifi 连接到 ADB。当我 运行 ant debug install 时,我会无限期地收到以下错误。

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

如果我断开其中一台设备,它会正常 运行。

我也试过了

ant debug install [特定设备的ip]

这提供了同样的错误结果。

有什么方法可以同时安装到两个设备上吗?

android ant 构建脚本似乎不支持在一个命令中安装到所有设备。但是,安装目标确实需要一个名为 ${adb.device.arg} 的 ant 属性。您至少应该能够从命令行控制要将应用程序安装到哪个设备,如下所示:

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

现在,如果您可以使用 here 中描述的脚本之一来检索所有已连接设备 ID 的列表,您应该能够编写一个简单的脚本来为每个设备迭代 ant install 命令.

顺便说一句,如果您有兴趣,ant build xml 文件作为 sdk 的一部分包含在您的 sdk 文件夹中:

$ANDROID_SDK/tools/ant/build.xml