I am creating a Jenkins node (on Mac OS X) that runs test cases for my Android application.
The My Jenkins project launches the Android emulator and launches the Gradle task :app:connectedAndroidTest. But the task was always unstable, sometimes it could run tests normally, but most of the time the following error did not execute:
:app:connectedAndroidTest FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:connectedAndroidTest'.
> com.android.builder.testing.api.DeviceException: No connected devices!
After some investigation, I found that:
- The problem only occurs on this machine; on my machine (another Mac OS X) the task always worked, as expected, inside and outside Android Studio;
- The problem occurs outside of Jenkins, that is, by manually starting the emulator and starting the Gradle task from the command line;
- , Jenkins , 5554-5555;
adb devices -;adb shell am instrument ;
, , :app:connectedAndroidTest .
script, APK am instrument, , JUnit.
, , , "" Gradle, .
, , . , Gradle .