在特定的模拟器中安装Apk

时间:2014-08-08 12:59:40

标签: android command-line android-emulator emulation

我尝试使用TeamCity在特定模拟器上安装apk。现在我正在启动模拟器并成功安装apk ..但如果已经有一个或多个模拟器运行的实例,团队城市无法决定在哪个模拟器中安装apk(即使我从teamcity启动模拟器)脚本)。

问题是我无法识别刚开始使用的模拟器:

emulator -adv myEmulator

它将在端口5554到5587之间启动一个模拟器...我知道我可以在我想要安装我的apk的地方设置模拟器实例:

adb -s emulator-5554 install path/apk

但是我不知道我刚刚开始的模拟器的id,所以它的名字中可以有任意数字。

我知道我可以将UUID设置为模拟器(来自here),但是再次..不知道如何使用该uuid。

现在我将尝试在使用BATCH运行自己之前保存可用的模拟器,然后比较两个数组以获取我的模拟器..但我不是BATCH的专家..所以如果有人有线索它是会有所帮助,

此致

1 个答案:

答案 0 :(得分:4)

您似乎在寻找-s的{​​{1}}选项:

adb

其他有用的选项:

   -s <specific device>       - directs command to the device or emulator with
                                the given serial number or qualifier.

一般 -d - directs command to the only connected USB device returns an error if more than one USB device is present. -e - directs command to the only running emulator. returns an error if more than one emulator is running. 全部查看。

修改

您可以定义模拟器要使用的端口:

adb -h

所以你可以手动分配端口而不用费心去猜测。为了避免端口冲突,您可以强制启动所有模拟器的端口(通常不应该同时运行3个)或者您可以为您的范围选择高端口号,足够高,以便启动任何其他模拟器将使用低于您范围的可用端口。

或者您可以解析在使用-ports <consoleport>,<adbport> TCP ports used for the console and adb bridge 开关时生成的模拟器日志,如您所见:

-verbose

如果要将模拟器日志保存到特定文件,请使用常规流重定向:

emulator: control console listening on port 5554, ADB on port 5555
emulator: sent '0012host:emulator:5555' to ADB server