Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Updated some stuff for release 3.0.
Section
Column

Wiki Markup
{jenkins-plugin-info:android-emulator}
Excerpt

Automates many Android development tasks including SDK installation, build file generation, emulator creation and launch, APK (un)installation, monkey testing and analysis...


See also: Android Lint Plugin.
See also: Google Play Android Publisher Plugin.

Column

Table of Contents

Table of Contents
minLevelmaxLevel2
maxLevelminLevel2
printablefalse

Features

This plugin lets you automate a number of Android-related tasks during a build:

...

Requirements

Jenkins

Jenkins version 12.609.332 or newer is required.

Android

...

For convenience, the plugin places a number of variables into the build environment relating to the emulator in use:

Variable name

Example value

Description

ANDROID_SERIAL

localhost:34564

Identifier for connecting to this AVD, e.g. adb -s localhost:34564 shell

ANDROID_AVD_DEVICE

localhost:34564

Identifier for connecting to this AVD, e.g. adb -s localhost:34564 shell

ANDROID_AVD_ADB_PORT

34564

Port used by ADB to communicate with the AVD (random for each build)

ANDROID_AVD_USER_PORT

40960

Port used to access the AVD's telnet user interface (random for each build)

ANDROID_AVD_NAME

hudson_en-GB_160_HVGA_android-7

Name of the AVD running for the build

ANDROID_AVD_LOCALE

en_GB

Locale of the AVD

ANDROID_AVD_OS

2.1

OS version of the running AVD

ANDROID_AVD_DENSITY

160

Screen density in dpi of the AVD

ANDROID_AVD_RESOLUTION

HVGA

Screen resolution, named or dimension, of the AVD

ANDROID_AVD_SKIN

HVGA

Skin being used by the AVD, e.g. WQVGA432 or 480x800

ANDROID_ADB_SERVER_PORT

51292

Port that the AVD server for this build is running on (random for each build)

ANDROID_TMP_LOGCAT_FILE

/var/tmp/logcat_943239.log

Temporary file to which logcat output is written during the build (random for each build)

JENKINS_ANDROID_HOME

/home/jenkins/tools/android-sdk

The path to the Android SDK being used for this build (optional)

ANDROID_HOME

/home/jenkins/tools/android-sdk

The path to the Android SDK being used for this build (optional)

Using the emulator

Now that you have an Android emulator running, you'll probably want to install one or more Android applications (APKs) and start running some tests.

...

Expand
titleView known issues...

Pipeline not yet supported

This plugin is currently still only compatible with Freestyle jobs — Pipeline support is planned!

Emulator v2

The new-and-improved emulator engine — first released as part of SDK Tools 25 (and Android Studio 2.0) — unfortunately does not work with this plugin at the moment (April 2016).This plugin depends on several features that were removed in the new emulator engine (e.g. Android bug #205204), and therefore the plugin ensures that the original, version 1 engine is usedis supported as of version 3.0 of this plugin.

However, the Quick Boot feature (formerly known as snapshots) is currently not supported, as the command line tools do not appear to support this.

Android SDK Tools

Due to a regression in SDK Tools r12 and r13 (see Android bug #18444), running any builds with the "Use emulator snapshots" option enabled (which is the default), would likely fail to load in the state you expect. For example the emulator may not be ready for use, and the screen may not be unlocked.

To avoid this, either keep using r11 or earlier, or update to r14 or newer. However, if you update, you will have to manually delete all existing snapshot images and allow this plugin to re-create them.
See the Known Issues page on the Android Tools site for more information.

Similarly, snapshot support does not fully function for Android 4.0 until SDK Tools r15. An initial snapshot can be created, but subsequently loading from that snapshot will crash the emulator immediately. Earlier Android versions are not affected, i.e. you can still use snapshots with Android 3.2 and earlier. Upgrading to SDK Tools r15+ should fix this.

As a workaround, you can also uncheck "Use emulator snapshots" in any jobs where you are seeing problems.

Running in a Windows service as "Local System"

New AVDs cannot be generated and run if Jenkins is running as a Windows service, using the "Local System" account (see JENKINS-7355).

  • Workaround: configure the Jenkins service to "run as" a real user

Emulator UI doesn't appear when running on Windows 7

If running Jenkins as a service on Windows 7 or newer, you may find that while the plugin can start an emulator, its user interface may not appear, even if configured to do so.
This is due to something called Session 0 Isolation, which prevents services from starting UIs for security reasons.

If you really need to see the emulator UI, you can either run Jenkins not as a service, or add a slave node to Jenkins (e.g. launch slave via JNLP on the same machine) which will bypass this isolation.

Unexpected timeouts or hanging during build

AVDs can, on occasion, time-out unexpectedly or stop responding during a build, e.g. when trying to install an APK (see JENKINS-7354).

  • This is generally caused by bugs in the ADB process. It can be prone to hanging or crashing. Over time, more safeguards have been added to the plugin, including timing-out after a while and isolating ADB instances, so this shouldn't happen too often.

This should also be more stable with version 3.0 of this plugin, which allows the new emulator engine to be used.

AVDs may not shut down fully at the end of a build

Sometimes the emulator process does not shut down fully at the end of a build (requiring a kill -9 on Linux); the plugin sends a console command to terminate the emulator and the UI window closes, but the actual emulator process does not die.

  • This issue will be fixed once JENKINS-11995 is implemented.
  • If your slave is running Linux, you may be running into Android issue #17294
    In this case, there is a workaround assuming your build doesn't need to use the emulator's audio input:
    • Add a custom hardware property called "hw.audioInput" with the value "no"

Potential upcoming features

Version history

Version 3.0 (December 4, 2017)

Many thanks to Michael Musenbrock for doing most of the heavy lifting on this release.

  • Added support for Android Emulator 2.0 (JENKINS-40178, JENKINS-43215, JENKINS-44490)

    • The QEMU2 engine will be used automatically, and should be faster and more stable

    • Older SDK Tools will be automatically upgraded to a modern version as appropriate

    • Fixed creation of non-default ABI images with SDK Tools < 25.3 (JENKINS-32737)

    • Thanks to Michael Musenbrock

  • Fixed to select the configured emulator executable when listing snapshots (JENKINS-34678)

  • Updated to non-deprecated artifact archiving mechanism (JENKINS-26941)

  • Added configuration-time check for application ID in the APK uninstall step (PR #53)

  • Fixed Findbugs warnings, reduced other warnings, and removed deprecated code usages (JENKINS-45456)

    • Thanks to Michael Musenbrock

  • Added a Jenkinsfile for ci.jenkins.io

  • Updated minimum Jenkins version to 2.32

Version 2.15 (May 23, 2016)

  • Ensure that newer emulators aren't left running when a build completes (JENKINS-35004)
    • This is required as SDK Tools 25.1.6 introduced a breaking change to the emulator console interface

...