Managing Android SDK

Issue

  • Missing Android SDK libraries are breaking your builds
  • Your build requires a newer SDK version

Environment

Resolution

We have a detailed, although a bit outdated, documentation on managing Android project on DEV@cloud here.

In September 2016, we updated our Android agent image to enhance the Android development experience. We now include all released SDK to date and most extra libraries (component list at the bottom of this page). We have decided to not include Android system images in order to reduce the disk usage on DEV@cloud and the extra space has allowed us to provide more Android SDKs. This means that in order to use the Android emulator, you need to install the system image for the systems you target.

To summarize the changes:

  • compiling Android projects should now just work
  • running tests involving the Android emulator requires an extra step to install the system image for the systems you target

Android SDKs are only available in agents with android label. You need to use that label in the job configuration to build with Android SDKs.

If by any chance a new SDK has just been released and is not yet available, you can install it manually by following the next paragraph.

Manually updating or installing Android components

Android agents are designed to let you update and install new components by yourself.

You have 2 options to install / update Android components:

  • use Install Android project prerequisites step of Android Emulator Plugin. This will work most of the time but sometimes the plugin might not be able to analyze the structure of your project
  • launch a shell script at the beginning of your build. That way, you will get better control of what is installed

Use a shell script to install / update Android components

In order to install or update Android components, you need to add a shell step at the beginning of the job configuration containing the following shell script:

(for i in {1..30}; do echo y; sleep 1; done) | echo "y" | /opt/android/android-sdk-linux/tools/android update sdk --no-ui --all --filter NAME_OF_THE_COMPONENT_I_NEED

--all is mandatory, otherwise, some tools can’t be downloaded.
--filter comma separated list of Android components to install.

To find out the list of installable components, launch this command:

/opt/android/android-sdk-linux/tools/android list sdk --no-ui -e -a

Let’s take an example, if you need to install the system image to run the emulator to run tests against Android 6.0 on a ARM target, you would add that shell step:

(for i in {1..30}; do echo y; sleep 1; done) | echo "y" | /opt/android/android-sdk-linux/tools/android update sdk --no-ui --all --filter sys-img-armeabi-v7a-android-23

Recommendation on agent workspace disk space usage

If the Android SDK installer is asked to install components which are already available, it will proceed and overwrite installed components. This can lead to increased storage requirements for the SDK and will over time contribute to your agent exceeding the disk quota limit. We advise you to take care to only install missing components with the –filter argument.

Pre-installed Android components

This is the list of available components in our Android agent (name as reported by android list sdk -e -a):

platform-tools
tools
build-tools-24.0.1
build-tools-24.0.0
build-tools-23.0.3
build-tools-23.0.2
build-tools-23.0.1
build-tools-23.0.0
build-tools-22.0.1
build-tools-22.0.0
build-tools-21.1.2
build-tools-21.1.1
build-tools-21.1.0
build-tools-21.0.2
build-tools-21.0.1
build-tools-21.0.0
build-tools-20.0.0
build-tools-19.1.0
build-tools-19.0.3
build-tools-19.0.2
build-tools-19.0.1
build-tools-19.0.0
build-tools-18.1.1
build-tools-18.1.0
build-tools-18.0.1
build-tools-17.0.0
build-tools-24.0.1
build-tools-24.0.0
build-tools-23.0.3
build-tools-23.0.2
build-tools-23.0.1
build-tools-23.0.0
build-tools-22.0.1
build-tools-22.0.0
build-tools-21.1.2
build-tools-21.1.1
build-tools-21.1.0
build-tools-21.0.2
build-tools-21.0.1
build-tools-21.0.0
build-tools-20.0.0
build-tools-19.1.0
build-tools-19.0.3
build-tools-19.0.2
build-tools-19.0.1
build-tools-19.0.0
build-tools-18.1.1
build-tools-18.1.0
build-tools-18.0.1
build-tools-17.0.0
android-24
android-23
android-22
android-21
android-20
android-19
android-18
android-17
android-16
android-15
android-14
android-13
android-12
android-11
android-10
android-9
android-8
android-7
addon-google_apis-google-23
addon-google_apis-google-22
addon-google_apis-google-21
addon-google_apis-google-19
addon-google_apis-google-18
addon-google_apis-google-17
addon-google_apis-google-16
addon-google_apis-google-15
addon-google_apis-google-14
addon-google_apis-google-13
addon-google_apis-google-12
addon-google_apis-google-11
addon-google_apis-google-10
addon-google_apis-google-9
addon-google_apis-google-8
addon-google_apis-google-7
addon-google_apis-google-6
addon-google_apis-google-5
addon-google_apis-google-4
addon-google_apis-google-3
extra-android-m2repository
extra-android-support
extra-google-admob_ads_sdk
extra-google-analytics_sdk_v2
extra-google-auto
extra-google-gcm
extra-google-google_play_services_froyo
extra-google-google_play_services
extra-google-m2repository
extra-google-market_apk_expansion
extra-google-market_licensing
extra-google-play_billing
extra-google-simulators
extra-google-webdriver
Have more questions? Submit a request

2 Comments

  • 0
    Avatar
    Mike_ch_1 Mike_ch_1

    Does anybody know how to do this on a windows box?

  • 0
    Avatar
    Godfrey Obinchu

    Am not getting lucky with this method. I have created a shell job and ran the command. 

Please sign in to leave a comment.