Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Emulator Jenkins Plugin not working

Tags:

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?

like image 845
valentina Avatar asked May 16 '14 15:05

valentina


People also ask

How does Jenkins integrate with Android?

1.4. To create an Android build job on Jenkins, select New Job, and enter a job name. Select the Build a free-style software project option. You now configure from where the source should be cloned. Configure you desired build trigger.


1 Answers

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!

like image 154
Karen Kraft Avatar answered Sep 25 '22 03:09

Karen Kraft