Running gradle's connectedAndroidTest on a specific device
android, android-gradle-plugin, gradle
Solution
Use the `ANDROID_SERIAL` variable
You can do this two ways:
1. Set environment variable
# Set once; all following gradlew commands will use this
export ANDROID_SERIAL=1000AB0123456YZ
./gradlew <...>
2. "Set" for just a command
ANDROID_SERIAL=1000AB0123456YZ ./gradlew <...>
If you set/exported ANDROID_SERIAL (method #1), you can use this to override that for a single command.
Note
This works with emulator identifiers (e.g., "emulator-5554"), too.
Problem
How do you run `connectedAndroidTest` on a particular device? I would expect something like: ``` ./gradlew connectedAndroidTest -DconnectedAndroidTest.device=XXXX ``` We have a number of devices plugged into our CI server and I can't seem to find any documentation on how to target a specific connected device. `connectedAndroidTest` runs the tests on ALL connected devices currently. Thanks.