ConnectedAndroidTest fails with “no connected devices”, but the device is working

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 .

+4
2

, Android, start-service comd commond adb.if , .

0

. - ? ant script, , adb , :

%ANDROID_SDK%-current\platform-tools\adb.exe devices
%ANDROID_SDK%-current\platform-tools\adb.exe root
%ANDROID_SDK%-current\platform-tools\adb.exe devices
%ANDROID_SDK%-current\platform-tools\adb.exe wait-for-device

.

0

Source: https://habr.com/ru/post/1682323/


All Articles