通过ddmlib获取安卓设备信息,配置jar
<dependency>
<groupId>com.android.tools.ddms</groupId>
<artifactId>ddmlib</artifactId>
<version>25.3.0</version>
</dependency>
获取app版本,执行测试如下:
@Test
@Description(description = "获取本机所连设备信息")
public void test1() throws Exception {
// executeCommand("adb connect 10.2.255.236:7441");
logger.info("获取所有连接的设备");
AndroidDebugBridge.init(false);
AndroidDebugBridge adb = Optional.ofNullable(AndroidDebugBridge.getBridge()).orElseGet(createAdb());
waitForDevice(adb);
for (IDevice iDevice : adb.getDevices()) {
System.out.println("当前设备:" + iDevice);
CollectingOutputReceiver