I have a simple test android project that I can test fine using ".\gradlew calabashDebug" in a DOS shell logged in as myself. However, when I run the project under Jenkins on a Continuous Integration server it fails during calabashDebug task because there are multiple Android Virtual Devices running:
$ C:\AndroidSDK\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk/tools/android.bat list target
[android] Using Android SDK: C:\AndroidSDK\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk
$ C:\AndroidSDK\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk/platform-tools/adb.exe start-server
$ C:\AndroidSDK\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk/tools/emulator.exe -snapshot-list -no-window -avd hudson_en-US_213_800x1280_android-17_x86
[android] Starting Android emulator and creating initial snapshot
[android] Erasing existing emulator data...
$ C:\AndroidSDK\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk/tools/emulator.exe -no-boot-anim -ports 50834,50835 -avd hudson_en-US_213_800x1280_android-17_x86 -no-snapshot-load -no-snapshot-save -wipe-data
* daemon not running. starting it now on port 50836 *
* daemon started successfully *
Failed to create Context 0x3005
emulator: WARNING: Could not initialize OpenglES emulation, using software renderer.
could not get wglGetExtensionsStringARB
could not get wglGetExtensionsStringARB
could not get wglGetExtensionsStringARB
could not get wglGetExtensionsStringARB
could not get wglGetExtensionsStringARB
could not get wglGetExtensionsStringARB
could not get wglGetExtensionsStringARB
could not get wglGetExtensionsStringARB
emulator: warning: opening audio output failed
$ C:\AndroidSDK\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk/platform-tools/adb.exe connect localhost:50835
[android] Waiting for emulator to finish booting...
$ C:\AndroidSDK\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk/platform-tools/adb.exe -s localhost:50835 shell getprop dev.bootcomplete
error: device not found
$ C:\AndroidSDK\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk/platform-tools/adb.exe connect localhost:50835
$ C:\AndroidSDK\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk/platform-tools/adb.exe -s localhost:50835 shell getprop dev.bootcomplete
error: device not found
$ C:\AndroidSDK\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk/platform-tools/adb.exe connect localhost:50835
$ C:\AndroidSDK\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk/platform-tools/adb.exe -s localhost:50835 shell getprop dev.bootcomplete
error: device not found
$ C:\AndroidSDK\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk/platform-tools/adb.exe disconnect localhost:50835
$ C:\AndroidSDK\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk/platform-tools/adb.exe connect localhost:50835
$ C:\AndroidSDK\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk/platform-tools/adb.exe -s localhost:50835 shell getprop dev.bootcomplete
error: device not found
$ C:\AndroidSDK\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk/platform-tools/adb.exe connect localhost:50835
$ C:\AndroidSDK\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk/platform-tools/adb.exe -s localhost:50835 shell getprop dev.bootcomplete
error: device not found
$ C:\AndroidSDK\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk/platform-tools/adb.exe connect localhost:50835
$ C:\AndroidSDK\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk/platform-tools/adb.exe -s localhost:50835 shell getprop dev.bootcomplete
error: device not found
$ C:\AndroidSDK\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk/platform-tools/adb.exe disconnect localhost:50835
$ C:\AndroidSDK\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk/platform-tools/adb.exe connect localhost:50835
$ C:\AndroidSDK\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk/platform-tools/adb.exe -s localhost:50835 shell getprop dev.bootcomplete
error: device not found
$ C:\AndroidSDK\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk/platform-tools/adb.exe connect localhost:50835
$ C:\AndroidSDK\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk/platform-tools/adb.exe -s localhost:50835 shell getprop dev.bootcomplete
error: device not found
$ C:\AndroidSDK\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk/platform-tools/adb.exe connect localhost:50835
$ C:\AndroidSDK\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk/platform-tools/adb.exe -s localhost:50835 shell getprop dev.bootcomplete
$ C:\AndroidSDK\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk/platform-tools/adb.exe disconnect localhost:50835
$ C:\AndroidSDK\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk/platform-tools/adb.exe connect localhost:50835
$ C:\AndroidSDK\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk/platform-tools/adb.exe -s localhost:50835 shell getprop dev.bootcomplete
$ C:\AndroidSDK\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk/platform-tools/adb.exe -s localhost:50835 logcat -v time
$ C:\AndroidSDK\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk/platform-tools/adb.exe connect localhost:50835
[android] Attempting to unlock emulator screen
$ C:\AndroidSDK\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk/platform-tools/adb.exe -s localhost:50835 shell input keyevent 82
$ C:\AndroidSDK\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk/platform-tools/adb.exe -s localhost:50835 shell input keyevent 4
[android] Giving the system some time to settle before creating initial snapshot...
$ C:\AndroidSDK\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk/platform-tools/adb.exe connect localhost:50835
$ C:\AndroidSDK\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk/platform-tools/adb.exe -s localhost:50835 logcat -c
$ C:\AndroidSDK\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk/platform-tools/adb.exe -s localhost:50835 shell log -p v -t Jenkins "Creating snapshot..."
[android] Creating snapshot...
$ C:\AndroidSDK\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk/platform-tools/adb.exe connect localhost:50835
[android] Emulator is ready for use (took 331 seconds)
[Gradle] - Launching build.
[workspace] $ cmd.exe /C '"C:\Users\jenkins\.jenkins\jobs\Toasty\workspace\gradlew.bat calabashDebug && exit %%ERRORLEVEL%%"'
:compileDebugNdk UP-TO-DATE
:preBuild
:preDebugBuild
:checkDebugManifest
:prepareDebugDependencies
:compileDebugAidl UP-TO-DATE
:compileDebugRenderscript UP-TO-DATE
:generateDebugBuildConfig UP-TO-DATE
:mergeDebugAssets UP-TO-DATE
:generateDebugResValues UP-TO-DATE
:generateDebugResources UP-TO-DATE
:mergeDebugResources UP-TO-DATE
:processDebugManifest UP-TO-DATE
:processDebugResources UP-TO-DATE
:generateDebugSources UP-TO-DATE
:compileDebugJava UP-TO-DATE
:preDexDebug UP-TO-DATE
:dexDebug UP-TO-DATE
:processDebugJavaRes UP-TO-DATE
:validateDebugSigning
:packageDebug UP-TO-DATE
:assembleDebug UP-TO-DATE
:calabashDebug
2014-04-25 08:24:36 - JDK found on PATH.
2014-04-25 08:24:36 - JDK found at: C:\Program Files\Java\jdk1.8.0
2014-04-25 08:24:36 - Android SDK found at: C:\AndroidSDK\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk
2014-04-25 08:24:37 - c:/Ruby193/bin/ruby.exe -S cucumber --format html --out C:\Users\jenkins\.jenkins\jobs\Toasty\workspace\build\reports\calabash\Debug\report.html -v MAIN_ACTIVITY=com.example.toasty.MainActivity APP_PATH="C:/Users/jenkins/.jenkins/jobs/Toasty/workspace/build/apk/workspace-debug-unaligned.apk" TEST_APP_PATH="test_servers/3ad00ebd6d3858b2667e3d4fef0e19e7_0.4.21.apk"
*** WARNING: You must use ANSICON 1.31 or higher (https://github.com/adoxa/ansicon/) to get coloured output on Windows
Code:
* features/support/env.rb
* features/support/app_installation_hooks.rb
* features/support/app_life_cycle_hooks.rb
* features/support/hooks.rb
* features/step_definitions/calabash_steps.rb
Features:
* features/my_first.feature
Parsing feature files took 0m0.009s
2014-04-25 08:24:38 - First scenario in feature - reinstalling apps
2014-04-25 08:24:38 - connected_devices: ["emulator-5556", "emulator-50834", "localhost:50835"]
2014-04-25 08:24:38 - connected_devices: ["emulator-5556", "emulator-50834", "localhost:50835"]
2014-04-25 08:24:38 - connected_devices: ["emulator-5556", "emulator-50834", "localhost:50835"]
:calabashDebug FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':calabashDebug'.
> Process 'command 'cmd'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
I am using the Jenkins Android Emulator Plugin to start an android virtual device using the following configuration:
- Run emulator with properties
- Show emulator window
- Use emulator snapshots
Why are there mutiple devices ("emulator-5556", "emulator-50834", "localhost:50835") started by the emulator plugin?
FWIW, I am unable to get the Jenkins Android Emulator Pluginb to work on Centos 6 either. So I am giving up on this promising looking plugin for now.
$ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:41704
$ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:41704 shell getprop dev.bootcomplete
error: device offline
$ /var/lib/jenkins/tools/android-sdk/platform-tools/adb disconnect localhost:41704
$ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:41704
[android] Timed-out after waiting 180 seconds for emulator
$ /var/lib/jenkins/tools/android-sdk/platform-tools/adb disconnect localhost:41704
[android] Stopping Android emulator