Testing multiple Android devices on one machine
Asked Answered
T

4

8

I have two different Android devices plugged into the same machine. What I would like to do is to target each device and execute a test on it separately.

Unfortunately, it seems as if I need to unplug one of the devices to run the test each time, because if I don't, I receive the following error:

error: more than one device and emulator

Does anyone know of a work-around for this issue so that I can simply keep both devices plugged in and run my tests?

Testaceous answered 28/11, 2012 at 20:17 Comment(4)
Are you running eclipse?Cancel
I am using calabash-android for testing and only have access to the app.apkTestaceous
ADB_DEVICE_ARG=<serial> calabash-android run <apk>Testaceous
is a possible solution as posted on groups.google.com/forum/#!topic/calabash-android/gFKPVgf9vMITestaceous
S
3

You need to set ADB_DEVICE_ARG environment variable to the serial number of your device as returned by adb devices.

So to add on to Robert's answer:

$ adb devices
List of devices attached 
emulator-5554  device
emulator-5556  device
emulator-5558  device

$ ADB_DEVICE_ARG=emulator-5554;calabash-android run yourapk.apk

If you need to run the same Calabash test at the same time on multiple devices, better run them from separate root folders, or specify the result in different folders so that the results don't get mixed up.

Sculpturesque answered 4/2, 2015 at 2:18 Comment(1)
If you're developing on Windows you can use SET to define the environmental variable. set ADB_DEVICE_ARG=emulator-5554 Then on the next line do your calabash-android run yourapk.apkRiot
L
2

You can specify the targeted device on the adb command with -s

1) Get the device serialNumber by doing

$ adb devices 
List of devices attached 
emulator-5554  device
emulator-5556  device
emulator-5558  device

2) Pass in the serialNumber into the adb command with -s argument

$ adb -s <serialNumber> <command> 

For example

$ adb -s emulator-5556 install helloWorld.apk
Litigant answered 19/12, 2012 at 1:50 Comment(0)
V
2

In the new Android Studio Artic Fox (it would have been Android Studio 4.3 in the previous numering system and at this moment is still in beta) you can run the tests in multiple machines at the same time.

https://developer.android.com/studio/preview/features?utm_source=android-studio-2020-3-1&utm_medium=studio-assistant-preview#instrumentation-testing

To take advantage of this feature:

  1. Choose Select Multiple Devices in the target device dropdown menu (in the top-center of the IDE).

enter image description here

  1. Select the target devices and click OK.

enter image description here

  1. Run your tests.

To view your test results in the Run panel, go to View > Tool Windows > Run.

Varion answered 13/2, 2021 at 12:4 Comment(0)
C
1

The below command works for me:

calabash-android run your_app.apk ADB_DEVICE_ARG=<your_device_id>

Hope that help

Canonicate answered 26/7, 2016 at 9:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.