Android Emulator Jenkins Plugin not working - android

I am trying to use the Jenkins Android Emulator with Cloudbees and I am often experiencing this kind of output:
error: device offline
$ /opt/android/android-sdk-linux/platform-tools/adb connect localhost:44194
$ /opt/android/android-sdk-linux/platform-tools/adb -s localhost:44194 shell getprop dev.bootcomplete
error: device offline
$ /opt/android/android-sdk-linux/platform-tools/adb connect localhost:44194
$ /opt/android/android-sdk-linux/platform-tools/adb -s localhost:44194 shell getprop dev.bootcomplete
error: device offline
$ /opt/android/android-sdk-linux/platform-tools/adb disconnect localhost:44194
$ /opt/android/android-sdk-linux/platform-tools/adb connect localhost:44194
$ /opt/android/android-sdk-linux/platform-tools/adb -s localhost:44194 shell getprop dev.bootcomplete
error: device offline
$ /opt/android/android-sdk-linux/platform-tools/adb connect localhost:44194
$ /opt/android/android-sdk-linux/platform-tools/adb -s localhost:44194 shell getprop dev.bootcomplete
error: device offline
$ /opt/android/android-sdk-linux/platform-tools/adb connect localhost:44194
$ /opt/android/android-sdk-linux/platform-tools/adb -s localhost:44194 shell getprop dev.bootcomplete
error: device offline
$ /opt/android/android-sdk-linux/platform-tools/adb disconnect localhost:44194
$ /opt/android/android-sdk-linux/platform-tools/adb connect localhost:44194
$ /opt/android/android-sdk-linux/platform-tools/adb -s localhost:44194 shell getprop dev.bootcomplete
error: device offline
$ /opt/android/android-sdk-linux/platform-tools/adb connect localhost:44194
$ /opt/android/android-sdk-linux/platform-tools/adb -s localhost:44194 shell getprop dev.bootcomplete
error: device offline
$ /opt/android/android-sdk-linux/platform-tools/adb connect localhost:44194
[android] Timed-out after waiting 720 seconds for emulator
$ /opt/android/android-sdk-linux/platform-tools/adb disconnect localhost:44194
[android] Stopping Android emulator
emulator: WARNING: Could not initialize OpenglES emulation, using software renderer.
$ /opt/android/android-sdk-linux/platform-tools/adb kill-server
Finished: NOT_BUILT
I am using andoird-19 as target but I have tried several.
I have also tried to reproduce the case on my local jenkins instance and it happens the same.
This gets worse when I try to load from snapshot: if I don't start from snapshot the emulator starts in the 50% of the cases, if I use the snapshots then it would always fail.
I am using emulator-arm as executable, since I read about some bugs with the 64bit version. Not sure it applies to r19 as well though.
Any idea?

The Jenkins Android Emulator issues I have had are legion. Here is a checklist to help:
1) You need the --all flag for both android list and android update sdk, otherwise some packages will not be installed: ex for SDK 24
1a)$ANDROID_HOME/tools/android list sdk --all
1b)
(for i in {1..100}; do echo y; sleep 1; done) |
$ANDROID_HOME/tools/android update sdk --no-ui --all --filter
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,20,21,22,23,24,25,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,79,80,81,82,82,84,85,101,102,103,112,113,117,118,119,120,121,122,123,124
If you get the dreaded /home/jenkins/android-sdk-linux/platform-tools/adb -s emulator-XXXX shell getprop dev.bootcomplete error: device offline error, you are likely missing a package in step 1b
2)Ignore the dreaded Failed to Initialize backend EGL display error, it is a red herring
3)Be sure to use the Advanced Emulator options:
Emulator Options: -no-audio -gpu off
Emulator executable: emulator64-arm
Startup delay: 10 -- this *may* help
4)a pre-build script ${ANDROID_HOME}/platform-tools/adb kill-server can't hurt
Good luck!

I started having the same problem after upgrading the Android Emulator plugin to 2.11.1. Downgrading to 2.10 via the plugin manager has proved itself to be an acceptable workaround for me.

Experiencing the same issue, using the Jenkins Android Emulator Plugin v2.13 with emulators running android-19 and above.
I found an open Jenkins ticket to fix the issue here.
Looks like a fix would require an update to the Android Emulator Plugin. In the meantime one workaround is to use a pre-android-19 emulator - I have not had the issue on android-16, android-17 or android-18 emulators.
An alternative workaround is to try downgrading the Android Emulator Plugin to v2.10, as #zachgeek suggested.

Related

Android Emulator is not started through Jenkins

I am trying to set up my mobile automation pack in Jenkins. As a first step, when I try to launch a emulator using Jenkins Android Emulator plugin, I am getting below error
Job Config
Android SDK details
Below is the error
$ C:\Users\Divakar\AppData\Local\Android\sdk/platform-tools/adb.exe start-server
[android] Snapshots are enabled, but cannot be used as they are not supported by the current SDK Tools
[android] Starting Android emulator
[android] Erasing existing emulator data...
$ C:\Users\Divakar\AppData\Local\Android\sdk/emulator/emulator.exe -ports 5764,5765 -report-console tcp:5850,max=60 -avd Pixel_2_Pie_9.0 -wipe-data -no-window
Failed to open /qemu.conf, err: 2
HAX is working and emulator runs in fast virt mode.
dsound: Could not set cooperative level for window 0000000000000000
dsound: Reason: An invalid parameter was passed to the returning function
audio: Could not init `dsound' audio driver
emulator: WARNING: Requested adb port (5765) is outside the recommended range [5555,5586]. ADB may not function properly for the emulator. See -help-port for details.
[android] Emulator reported that the console is available on port 5,764
[android] Waiting for emulator to finish booting...
$ C:\Users\Divakar\AppData\Local\Android\sdk/platform-tools/adb.exe -s emulator-5764 wait-for-device shell getprop dev.bootcomplete
ERROR: Timeout after 90000 milliseconds
$ C:\Users\Divakar\AppData\Local\Android\sdk/platform-tools/adb.exe -s emulator-5764 wait-for-device shell getprop dev.bootcomplete
emulator: INFO: boot completed
emulator: Increasing screen off timeout, logcat buffer size to 2M.
emulator: Revoking microphone permissions for Google App.
ERROR: Timeout after 90000 milliseconds
$ C:\Users\Divakar\AppData\Local\Android\sdk/platform-tools/adb.exe -s emulator-5764 wait-for-device shell getprop dev.bootcomplete
ERROR: Timeout after 90000 milliseconds
$ C:\Users\Divakar\AppData\Local\Android\sdk/platform-tools/adb.exe -s emulator-5764 wait-for-device shell getprop dev.bootcomplete
ERROR: Timeout after 90000 milliseconds
$ C:\Users\Divakar\AppData\Local\Android\sdk/platform-tools/adb.exe -s emulator-5764 wait-for-device shell getprop dev.bootcomplete
ERROR: Timeout after 90000 milliseconds
$ C:\Users\Divakar\AppData\Local\Android\sdk/platform-tools/adb.exe -s emulator-5764 wait-for-device shell getprop dev.bootcomplete
ERROR: Timeout after 90000 milliseconds
$ C:\Users\Divakar\AppData\Local\Android\sdk/platform-tools/adb.exe -s emulator-5764 wait-for-device shell getprop dev.bootcomplete
ERROR: Timeout after 90000 milliseconds
[android] Timed-out after waiting 720 seconds for emulator
[android] Stopping Android emulator
$ C:\Users\Divakar\AppData\Local\Android\sdk/platform-tools/adb.exe kill-server
emulator: Saving state on exit with session uptime 730379 ms
Finished: NOT_BUILT
After reducing the emulator RAM to 768MB, I can rid off the above issue. However I cant see any devices connected in adb devices command. If you see the below log, it started and immediately stopped.
Building in workspace C:\Program Files\Jenkins\Jenkins.jenkins\workspace\AVD_Manager_Start_Emulator
[android] Failed to create file or directory: C:\WINDOWS\system32\config\systemprofile\.android
[android] Using Android SDK: C:\Users\Divakar\AppData\Local\Android\sdk
$ C:\Users\Divakar\AppData\Local\Android\sdk/platform-tools/adb.exe start-server
* daemon not running; starting now at tcp:5813
* daemon started successfully
$ C:\Users\Divakar\AppData\Local\Android\sdk/platform-tools/adb.exe start-server
[android] Snapshots are enabled, but cannot be used as they are not supported by the current SDK Tools
[android] Starting Android emulator
[android] Erasing existing emulator data...
$ C:\Users\Divakar\AppData\Local\Android\sdk/emulator/emulator.exe -ports 5754,5755 -report-console tcp:5838,max=60 -avd Pixel_2_Pie_9.0 -wipe-data -no-window
Failed to open /qemu.conf, err: 2
HAX is working and emulator runs in fast virt mode.
dsound: Could not set cooperative level for window 0000000000000000
dsound: Reason: An invalid parameter was passed to the returning function
audio: Could not init `dsound' audio driver
emulator: WARNING: Requested adb port (5755) is outside the recommended range [5555,5586]. ADB may not function properly for the emulator. See -help-port for details.
[android] Emulator reported that the console is available on port 5,754
[android] Waiting for emulator to finish booting...
$ C:\Users\Divakar\AppData\Local\Android\sdk/platform-tools/adb.exe -s emulator-5754 wait-for-device shell getprop dev.bootcomplete
[android] Emulator reported that the startup process is ''
$ C:\Users\Divakar\AppData\Local\Android\sdk/platform-tools/adb.exe -s emulator-5754 wait-for-device shell getprop dev.bootcomplete
[android] Emulator reported that the startup process is ''
$ C:\Users\Divakar\AppData\Local\Android\sdk/platform-tools/adb.exe -s emulator-5754 wait-for-device shell getprop dev.bootcomplete
[android] Emulator reported that the startup process is ''
$ C:\Users\Divakar\AppData\Local\Android\sdk/platform-tools/adb.exe -s emulator-5754 wait-for-device shell getprop dev.bootcomplete
[android] Emulator reported that the startup process is ''
$ C:\Users\Divakar\AppData\Local\Android\sdk/platform-tools/adb.exe -s emulator-5754 wait-for-device shell getprop dev.bootcomplete
[android] Emulator reported that the startup process is ''
$ C:\Users\Divakar\AppData\Local\Android\sdk/platform-tools/adb.exe -s emulator-5754 wait-for-device shell getprop dev.bootcomplete
[android] Emulator reported that the startup process is ''
$ C:\Users\Divakar\AppData\Local\Android\sdk/platform-tools/adb.exe -s emulator-5754 wait-for-device shell getprop dev.bootcomplete
[android] Emulator reported that the startup process is ''
$ C:\Users\Divakar\AppData\Local\Android\sdk/platform-tools/adb.exe -s emulator-5754 wait-for-device shell getprop dev.bootcomplete
[android] Emulator reported that the startup process is ''
$ C:\Users\Divakar\AppData\Local\Android\sdk/platform-tools/adb.exe -s emulator-5754 wait-for-device shell getprop dev.bootcomplete
[android] Emulator reported that the startup process is ''
$ C:\Users\Divakar\AppData\Local\Android\sdk/platform-tools/adb.exe -s emulator-5754 wait-for-device shell getprop dev.bootcomplete
[android] Emulator reported that the startup process is ''
$ C:\Users\Divakar\AppData\Local\Android\sdk/platform-tools/adb.exe -s emulator-5754 wait-for-device shell getprop dev.bootcomplete
[android] Emulator reported that the startup process is ''
$ C:\Users\Divakar\AppData\Local\Android\sdk/platform-tools/adb.exe -s emulator-5754 wait-for-device shell getprop dev.bootcomplete
[android] Emulator reported that the startup process is ''
$ C:\Users\Divakar\AppData\Local\Android\sdk/platform-tools/adb.exe -s emulator-5754 wait-for-device shell getprop dev.bootcomplete
[android] Emulator reported that the startup process is ''
$ C:\Users\Divakar\AppData\Local\Android\sdk/platform-tools/adb.exe -s emulator-5754 wait-for-device shell getprop dev.bootcomplete
[android] Emulator reported that the startup process is ''
$ C:\Users\Divakar\AppData\Local\Android\sdk/platform-tools/adb.exe -s emulator-5754 wait-for-device shell getprop dev.bootcomplete
[android] Emulator reported that the startup process is ''
$ C:\Users\Divakar\AppData\Local\Android\sdk/platform-tools/adb.exe -s emulator-5754 wait-for-device shell getprop dev.bootcomplete
[android] Emulator reported that the startup process is ''
$ C:\Users\Divakar\AppData\Local\Android\sdk/platform-tools/adb.exe -s emulator-5754 wait-for-device shell getprop dev.bootcomplete
[android] Emulator reported that the startup process is ''
emulator: INFO: boot completed
emulator: Increasing screen off timeout, logcat buffer size to 2M.
emulator: Revoking microphone permissions for Google App.
$ C:\Users\Divakar\AppData\Local\Android\sdk/platform-tools/adb.exe -s emulator-5754 wait-for-device shell getprop dev.bootcomplete
[android] Emulator reported that the startup process is '1'
$ C:\Users\Divakar\AppData\Local\Android\sdk/platform-tools/adb.exe -s emulator-5754 shell logcat -v time
[android] Emulator is ready for use (took 283 seconds)
[AVD_Manager_Start_Emulator] $ cmd /c call C:\WINDOWS\TEMP\jenkins8495526174755772173.bat
C:\Program Files\Jenkins\Jenkins.jenkins\workspace\AVD_Manager_Start_Emulator>exit 0
[android] Stopping Android emulator
emulator: Saving state on exit with session uptime 257552 ms
[android] Archiving emulator log
$ C:\Users\Divakar\AppData\Local\Android\sdk/platform-tools/adb.exe kill-server
Finished: SUCCESS
The issue has been resolved. Please find the steps that I have followed
Uninstall Jenkins
Install war file
Thats all

How to check Android OS version of bluestacks Emulator

I searched a lot for this in Google, but no hope, how to check the OS version of Bluestacks emulator in Windows? There is a video in YouTube for checking bluestack version, but not the Android version used in it.
I went to settings – > Advanced settings, but there was no tab corresponding to About tab which is found in an Android emulator like in the case of Genymotion emulator.
There is an easier way of getting to know the android version without having to install any application.
There are some scripts (php/js) that can detect your android version while visiting websites:
Try; http://demo.mobiledetect.net/ Or;
http://detectmobilebrowsers.com/
Install Terminal Emulator from Play Store, open the application and type:
getprop ro.build.version.release
you will get something like: 4.4.4 for KitKat.
or
getprop ro.build.version.sdk for getting the sdk version which will return 19
Open a browser in Bluestacks and go to http://demo.mobiledetect.net
I have tested this on multiple devices of which the Android version is known, and it is accurate.
Currently responds to Bluestacks as v4.4.2 (Kitkat)
Without any installation, you could use your adb commands.
For example, for your main emulator
adb -s emulator-5554 shell getprop ro.build.version.release
adb -s emulator-5554 shell getprop ro.build.version.sdk
For your multi emulators add up by 10,
adb -s emulator-5564 shell getprop ro.build.version.release
adb -s emulator-5564 shell getprop ro.build.version.sdk
adb -s emulator-5574 shell getprop ro.build.version.release
adb -s emulator-5574 shell getprop ro.build.version.sdk
//... so on
You could also do the shell commands by their local ip,
adb -s 127.0.0.1:5555 shell getprop ro.build.version.release
adb -s 127.0.0.1:5555 shell getprop ro.build.version.sdk
adb -s 127.0.0.1:5565 shell getprop ro.build.version.release
adb -s 127.0.0.1:5565 shell getprop ro.build.version.sdk
adb -s 127.0.0.1:5575 shell getprop ro.build.version.release
adb -s 127.0.0.1:5575 shell getprop ro.build.version.sdk
//... so on
just use Droid Info .. which gives you alot of Information quite easely.

Android Emulator on Jenkins error: device offline

I have installed the Android Emulator plugin for Jenkins. I can build and test an Android-project. My Jenkins is running on an Ubuntu-server (only access with terminal). The project is pulled from Github. Now I want to use the Emulator. This is my configuration:
Android OS version: 4.4
Screen density: 160
Screen resolution: 480x800
Target ABI:armeabi-v7a
I also installed adb and did the following command:
/opt/android-sdk-linux/tools/android update sdk --no-ui
But it doesn't work:
> /usr/bin/git rev-list 3440b28279e2e95113ce1c9499d9d881e76f6810 # timeout=10
$ /opt/android-sdk-linux/tools/android list target
[android] Using Android SDK: /opt/android-sdk-linux
$ /opt/android-sdk-linux/platform-tools/adb start-server
* daemon not running. starting it now on port 7767 *
* daemon started successfully *
$ /opt/android-sdk-linux/platform-tools/adb start-server
[android] Starting Android emulator
$ /opt/android-sdk-linux/tools/emulator -ports 7765,7766 -prop persist.sys.language=en -prop persist.sys.country=US -avd hudson_en-US_160_WVGA_android-19_armeabi-v7a -no-snapshot-load -no-snapshot-save -no-window
Failed to Initialize backend EGL display
Could not initialize emulated framebufferemulator: WARNING: Could not initialize OpenglES emulation, using software renderer.
emulator: warning: opening audio output failed
$ /opt/android-sdk-linux/platform-tools/adb connect localhost:7766
connected to localhost:7766
[android] Waiting for emulator to finish booting...
$ /opt/android-sdk-linux/platform-tools/adb -s localhost:7766 shell getprop init.svc.bootanim
error: device offline
$ /opt/android-sdk-linux/platform-tools/adb connect localhost:7766
$ /opt/android-sdk-linux/platform-tools/adb -s localhost:7766 shell getprop init.svc.bootanim
error: device offline
...
$ /opt/android-sdk-linux/platform-tools/adb connect localhost:7766
[android] Interrupted while waiting for emulator to finish booting.
[android] Emulator was shut down before it finished booting
$ /opt/android-sdk-linux/platform-tools/adb disconnect localhost:7766
[android] Stopping Android emulator
$ /opt/android-sdk-linux/platform-tools/adb kill-server
Archiving artifacts
Recording test results
ERROR: Publisher hudson.tasks.junit.JUnitResultArchiver aborted due to exception
hudson.AbortException: Test reports were found but none of them are new. Did tests run?
For example, AndroidManifest.xml is 10 min old
Is there someone with an explanation for this issue? Thanks
I face the same issue, even when trying the commands manually.
But I could solve the issue when using ports like 5555,5556 according to that comment: JENKINS-27456
There is an associated pull request: PR on github
I will see if I have time to get and test a build with that patch and will let you know if it solves that problem.

Android emulator plugin, launcher icon is not found

I am using Android emulator plugin with jenkins. Along with the android application, I also have a java project for uiautomator which is the part of build modules in main pom.
The maven goal is : mvn install
The uiautomator test is failing at the point where it is trying to assert the presence of application launch icon from "Apps" screen.
Do I have to install the application apk or does the plugin does it automatically as described in the plugin documentation(My plugin version is 2.10 and jennkins version is 1.531)
How do i know that the application is installed in the emulator.
The emulator is started without any problem.
The following is the part of the jenkins log:
[android] Starting Android emulator $ /var/lib/jenkins/tools/android-sdk/tools/emulator -no-boot-anim -ports 35965,56985 -prop persist.sys.language=en -prop persist.sys.country=US
-avd hudson_en-US_120_800x1280_android-18_armeabi-v7a -no-snapshot-load -no-snapshot-save -no-window
* daemon not running. starting it now on port 42120 *
* daemon started successfully *
Failed to Initialize backend EGL display
$ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:56985 [android] Waiting for emulator to finish booting... $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:56985 shell getprop dev.bootcomplete error: device offline $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:56985
$ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:56985 shell getprop dev.bootcomplete error: device offline $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:56985
$ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:56985 shell getprop dev.bootcomplete error: device offline $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb disconnect localhost:56985 $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:56985
$ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:56985 shell getprop dev.bootcomplete $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:56985
$ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:56985 shell getprop dev.bootcomplete $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:56985
$ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:56985 shell getprop dev.bootcomplete $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb disconnect localhost:56985 $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:56985
$ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:56985 shell getprop dev.bootcomplete $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:56985
$ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:56985 shell getprop dev.bootcomplete $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:56985
$ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:56985 shell getprop dev.bootcomplete $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:56985 logcat -v time
$ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:56985 [android] Attempting to unlock emulator screen $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:56985 shell input keyevent 82
$ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:56985 shell input keyevent 4
$ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:56985 [android] Emulator is ready for use (took 97 seconds)
Do I have to install the application apk or does the plugin does it automatically as described in the plugin documentation
The documentation does not say that your APK will be automatically installed.
But the plugin does provide a build step which will do this for you, if you provide the path to an APK file:
Under the "Build" section of your job configuration, select "Add build step" and choose "Install Android package".
In the "APK file" field that appears, enter the filename of the APK you wish to install. When a build runs, the APK will be automatically installed after the emulator has started up.

Why is Jenkins Android Emulator Plugin recreating my Emulator Snapshots in every build?

I use Jenkins to build one of my projects. The Android Emulator Plugin automatically starts an emulator with the following configuration:
Configuration of the Emulator Plugin:
.
Every time the job is running I get the following output:
Erasing existing emulator data... $
/ci/home/tools/android-sdk//tools/emulator -no-boot-anim -ports
64470,64471 -prop persist.sys.language=de -prop persist.sys.country=DE
-avd hudson_de-DE_240_480x720_Google_Inc._Google_APIs_8 -no-snapshot-load -no-snapshot-save -wipe-data
.
.
shell input keyevent 4 [android] Giving the system some time to settle
before creating initial snapshot... $
.
.
localhost:64471 shell log -p v -t Jenkins "Creating snapshot..."
[android] Creating snapshot... $
Full log below.
It seems that the plugin is creating a new emulator every time and is not using snapshots.
This takes something between 2 and 4 minutes depending on the emulator configuration.
The plugin creates .avd and .ini files in the .android/avd directory inside the job folder. The avds are not deleted after the run process.
If I disable the use snapshots config the emulator needs less then a minute to start.
Is this an issue with the emulator plugin or are snapshots not possible because of my configuration?
I hope that using snapshots will speed up my building process a lot.
Full log:
$ /ci/home/tools/android-sdk//tools/android list target [android]
Using Android SDK: /ci/home/tools/android-sdk/ [android] Adding 200M
SD card to AVD 'hudson_de-DE_240_480x720_Google_Inc._Google_APIs_8'...
[android] Setting hardware properties: hw.ramSize: 512
$ /ci/home/tools/android-sdk//platform-tools/adb start-server
$ /ci/home/tools/android-sdk//tools/emulator -snapshot-list -no-window -avd hudson_de-DE_240_480x720_Google_Inc._Google_APIs_8
[android] Starting Android emulator and creating initial snapshot
[android] Erasing existing emulator data...
$ /ci/home/tools/android-sdk//tools/emulator -no-boot-anim -ports 64470,64471 -prop persist.sys.language=de -prop persist.sys.country=DE -avd hudson_de-DE_240_480x720_Google_Inc._Google_APIs_8 -no-snapshot-load -no-snapshot-save -wipe-data
* daemon not running. starting it now on port 64472 *
* daemon started successfully *
$ /ci/home/tools/android-sdk//platform-tools/adb connect localhost:64471
[android] Waiting for emulator to finish booting...
$ /ci/home/tools/android-sdk//platform-tools/adb -s localhost:64471
shell getprop dev.bootcomplete error: device offline
$ /ci/home/tools/android-sdk//platform-tools/adb connect localhost:64471
$ /ci/home/tools/android-sdk//platform-tools/adb -s localhost:64471 shell getprop dev.bootcomplete
$ /ci/home/tools/android-sdk//platform-tools/adb connect localhost:64471
$ /ci/home/tools/android-sdk//platform-tools/adb -s localhost:64471 shell getprop dev.bootcomplete
$ /ci/home/tools/android-sdk//platform-tools/adb disconnect localhost:64471
$ /ci/home/tools/android-sdk//platform-tools/adb connect localhost:64471
$ /ci/home/tools/android-sdk//platform-tools/adb -s localhost:64471 shell getprop dev.bootcomplete
$ /ci/home/tools/android-sdk//platform-tools/adb connect localhost:64471
$ /ci/home/tools/android-sdk//platform-tools/adb -s localhost:64471 shell getprop dev.bootcomplete
$ /ci/home/tools/android-sdk//platform-tools/adb connect localhost:64471
$ /ci/home/tools/android-sdk//platform-tools/adb -s localhost:64471 shell getprop dev.bootcomplete
$ /ci/home/tools/android-sdk//platform-tools/adb -s localhost:64471 logcat -v time
$ /ci/home/tools/android-sdk//platform-tools/adb connect localhost:64471
[android] Attempting to unlock emulator screen
$ /ci/home/tools/android-sdk//platform-tools/adb -s localhost:64471 shell input keyevent 82
$ /ci/home/tools/android-sdk//platform-tools/adb -s localhost:64471 shell input keyevent 4
[android] Giving the system some time to settle before creating initial snapshot...
$ /ci/home/tools/android-sdk//platform-tools/adb connect localhost:64471
$ /ci/home/tools/android-sdk//platform-tools/adb -s localhost:64471 logcat -c
$ /ci/home/tools/android-sdk//platform-tools/adb -s localhost:64471 shell log -p v -t Jenkins "Creating snapshot..."
[android] Creating snapshot...
$ /ci/home/tools/android-sdk//platform-tools/adb connect localhost:64471
[android] Emulator is ready for use (took 158 seconds)
Buildfile for an example job:
<?xml version='1.0' encoding='UTF-8'?>
<project>
<actions/>
<description></description>
<keepDependencies>false</keepDependencies>
<properties/>
<scm class="hudson.plugins.git.GitSCM">
<configVersion>2</configVersion>
<userRemoteConfigs>
<hudson.plugins.git.UserRemoteConfig>
<name></name>
<refspec></refspec>
<url>git#project...</url>
</hudson.plugins.git.UserRemoteConfig>
</userRemoteConfigs>
<branches>
<hudson.plugins.git.BranchSpec>
<name>master</name>
</hudson.plugins.git.BranchSpec>
</branches>
<disableSubmodules>false</disableSubmodules>
<recursiveSubmodules>false</recursiveSubmodules>
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
<authorOrCommitter>false</authorOrCommitter>
<clean>false</clean>
<wipeOutWorkspace>false</wipeOutWorkspace>
<pruneBranches>false</pruneBranches>
<remotePoll>false</remotePoll>
<ignoreNotifyCommit>false</ignoreNotifyCommit>
<useShallowClone>false</useShallowClone>
<buildChooser class="hudson.plugins.git.util.DefaultBuildChooser"/>
<gitTool>default</gitTool>
<submoduleCfg class="list"/>
<relativeTargetDir></relativeTargetDir>
<reference></reference>
<excludedRegions></excludedRegions>
<excludedUsers></excludedUsers>
<gitConfigName></gitConfigName>
<gitConfigEmail></gitConfigEmail>
<skipTag>false</skipTag>
<includedRegions></includedRegions>
<scmName></scmName>
</scm>
<canRoam>true</canRoam>
<disabled>false</disabled>
<blockBuildWhenDownstreamBuilding>true</blockBuildWhenDownstreamBuilding>
<blockBuildWhenUpstreamBuilding>true</blockBuildWhenUpstreamBuilding>
<triggers class="vector">
<hudson.triggers.SCMTrigger>
<spec>*/5 * * * *</spec>
</hudson.triggers.SCMTrigger>
</triggers>
<concurrentBuild>false</concurrentBuild>
<builders>
<hudson.tasks.Ant>
<targets>clean debug install</targets>
<antName>(Default)</antName>
</hudson.tasks.Ant>
<hudson.tasks.Ant>
<targets></targets>
<antName>(Default)</antName>
<buildFile>checkstyle-ant.xml</buildFile>
</hudson.tasks.Ant>
<hudson.tasks.Shell>
<command>os_opts="-Djava.awt.headless=true" lint --xml lint-results.xml .</command>
</hudson.tasks.Shell>
<hudson.plugins.android__emulator.monkey.MonkeyBuilder>
<packageId>de....</packageId>
<eventCount>1000</eventCount>
<throttleMs>10</throttleMs>
<seed>timestamp</seed>
</hudson.plugins.android__emulator.monkey.MonkeyBuilder>
<hudson.tasks.Shell>
... distribution script
</hudson.tasks.Shell>
</builders>
<publishers>
<org.jenkinsci.plugins.android__lint.LintPublisher>
<healthy></healthy>
<thresholdLimit>low</thresholdLimit>
<pluginName>[android-lint] </pluginName>
<defaultEncoding></defaultEncoding>
<canRunOnFailed>false</canRunOnFailed>
<useStableBuildAsReference>false</useStableBuildAsReference>
<useDeltaValues>false</useDeltaValues>
<thresholds>
<unstableTotalAll></unstableTotalAll>
<unstableTotalHigh></unstableTotalHigh>
<unstableTotalNormal></unstableTotalNormal>
<unstableTotalLow></unstableTotalLow>
<unstableNewAll></unstableNewAll>
<unstableNewHigh></unstableNewHigh>
<unstableNewNormal></unstableNewNormal>
<unstableNewLow></unstableNewLow>
<failedTotalAll></failedTotalAll>
<failedTotalHigh></failedTotalHigh>
<failedTotalNormal></failedTotalNormal>
<failedTotalLow></failedTotalLow>
<failedNewAll></failedNewAll>
<failedNewHigh></failedNewHigh>
<failedNewNormal></failedNewNormal>
<failedNewLow></failedNewLow>
</thresholds>
<shouldDetectModules>false</shouldDetectModules>
<dontComputeNew>false</dontComputeNew>
<doNotResolveRelativePaths>false</doNotResolveRelativePaths>
<pattern></pattern>
</org.jenkinsci.plugins.android__lint.LintPublisher>
<hudson.plugins.checkstyle.CheckStylePublisher>
<healthy></healthy>
<unHealthy></unHealthy>
<thresholdLimit>low</thresholdLimit>
<pluginName>[CHECKSTYLE] </pluginName>
<defaultEncoding></defaultEncoding>
<canRunOnFailed>false</canRunOnFailed>
<useStableBuildAsReference>false</useStableBuildAsReference>
<useDeltaValues>false</useDeltaValues>
<thresholds>
<unstableTotalAll></unstableTotalAll>
<unstableTotalHigh></unstableTotalHigh>
<unstableTotalNormal></unstableTotalNormal>
<unstableTotalLow></unstableTotalLow>
<failedTotalAll></failedTotalAll>
<failedTotalHigh></failedTotalHigh>
<failedTotalNormal></failedTotalNormal>
<failedTotalLow></failedTotalLow>
</thresholds>
<shouldDetectModules>false</shouldDetectModules>
<dontComputeNew>true</dontComputeNew>
<doNotResolveRelativePaths>false</doNotResolveRelativePaths>
<pattern></pattern>
</hudson.plugins.checkstyle.CheckStylePublisher>
<hudson.plugins.warnings.WarningsPublisher>
<healthy></healthy>
<unHealthy></unHealthy>
<thresholdLimit>low</thresholdLimit>
<pluginName>[WARNINGS] </pluginName>
<defaultEncoding></defaultEncoding>
<canRunOnFailed>false</canRunOnFailed>
<useStableBuildAsReference>false</useStableBuildAsReference>
<useDeltaValues>false</useDeltaValues>
<thresholds>
<unstableTotalAll></unstableTotalAll>
<unstableTotalHigh></unstableTotalHigh>
<unstableTotalNormal></unstableTotalNormal>
<unstableTotalLow></unstableTotalLow>
<failedTotalAll></failedTotalAll>
<failedTotalHigh></failedTotalHigh>
<failedTotalNormal></failedTotalNormal>
<failedTotalLow></failedTotalLow>
</thresholds>
<shouldDetectModules>false</shouldDetectModules>
<dontComputeNew>true</dontComputeNew>
<doNotResolveRelativePaths>true</doNotResolveRelativePaths>
<parserConfigurations/>
<consoleParsers>
<hudson.plugins.warnings.ConsoleParser>
<parserName>Java Compiler (Eclipse)</parserName>
</hudson.plugins.warnings.ConsoleParser>
</consoleParsers>
</hudson.plugins.warnings.WarningsPublisher>
<hudson.plugins.analysis.collector.AnalysisPublisher>
<healthy></healthy>
<unHealthy></unHealthy>
<thresholdLimit>low</thresholdLimit>
<pluginName>[ANALYSIS-COLLECTOR] </pluginName>
<defaultEncoding></defaultEncoding>
<canRunOnFailed>false</canRunOnFailed>
<useStableBuildAsReference>false</useStableBuildAsReference>
<useDeltaValues>false</useDeltaValues>
<thresholds>
<unstableTotalAll></unstableTotalAll>
<unstableTotalHigh></unstableTotalHigh>
<unstableTotalNormal></unstableTotalNormal>
<unstableTotalLow></unstableTotalLow>
<failedTotalAll></failedTotalAll>
<failedTotalHigh></failedTotalHigh>
<failedTotalNormal></failedTotalNormal>
<failedTotalLow></failedTotalLow>
</thresholds>
<shouldDetectModules>false</shouldDetectModules>
<dontComputeNew>true</dontComputeNew>
<doNotResolveRelativePaths>true</doNotResolveRelativePaths>
<isCheckStyleDeactivated>false</isCheckStyleDeactivated>
<isDryDeactivated>true</isDryDeactivated>
<isFindBugsDeactivated>true</isFindBugsDeactivated>
<isPmdDeactivated>true</isPmdDeactivated>
<isOpenTasksDeactivated>true</isOpenTasksDeactivated>
<isWarningsDeactivated>false</isWarningsDeactivated>
</hudson.plugins.analysis.collector.AnalysisPublisher>
<hudson.plugins.android__emulator.monkey.MonkeyRecorder>
<failureOutcome>FAILURE</failureOutcome>
</hudson.plugins.android__emulator.monkey.MonkeyRecorder>
<hudson.plugins.cigame.GamePublisher/>
<hudson.tasks.Mailer>
<recipients></recipients>
<dontNotifyEveryUnstableBuild>false</dontNotifyEveryUnstableBuild>
<sendToIndividuals>true</sendToIndividuals>
</hudson.tasks.Mailer>
</publishers>
<buildWrappers>
<hudson.plugins.locksandlatches.LockWrapper>
<locks>
<hudson.plugins.locksandlatches.LockWrapper_-LockWaitConfig>
<name>AndroidEmulator</name>
</hudson.plugins.locksandlatches.LockWrapper_-LockWaitConfig>
</locks>
</hudson.plugins.locksandlatches.LockWrapper>
<hudson.plugins.android__emulator.AndroidEmulator>
<osVersion>Google Inc.:Google APIs:8</osVersion>
<screenDensity>240</screenDensity>
<screenResolution>480x720</screenResolution>
<deviceLocale>de_DE</deviceLocale>
<sdCardSize>200M</sdCardSize>
<hardwareProperties>
<hudson.plugins.android__emulator.AndroidEmulator_-HardwareProperty>
<key>hw.ramSize</key>
<value>512</value>
</hudson.plugins.android__emulator.AndroidEmulator_-HardwareProperty>
</hardwareProperties>
<wipeData>false</wipeData>
<showWindow>true</showWindow>
<useSnapshots>true</useSnapshots>
<deleteAfterBuild>false</deleteAfterBuild>
<startupDelay>0</startupDelay>
<commandLineOptions></commandLineOptions>
</hudson.plugins.android__emulator.AndroidEmulator>
</buildWrappers>
</project>
A bug was introduced in SDK Tools r20, whereby trying to list the available snapshots (via the emulator -snapshot-list command) would result in a crash.
Since the command crashes without listing the available snapshots, the Android Emulator Plugin believes that there are no existing snapshots, which causes a new snapshot to be created in every build.
I discovered that these crashes only occur with certain versions of the emulator application, i.e. it is possible to avoid the crash.
Thankfully, the Jenkins plugin lets you select the emulator binary to run.
So you can work around this problem by going into your job configuration, pressing Advanced… in the emulator config and selecting the "emulator-arm" (or another) binary.
In addition to Christopher Orr's answer, there is another possible cause. In my environment, emulator -snapshot-list listed the size of my snapshot as "1.0G". The pattern that matches snapshots in the Android Emulator Plugin as of 2014-01-14 matches whole number megabyte values.
I submitted a pull request to address that cause.

Categories

Resources