Installing Android dependencies - android-update-sdk: command not found

Hi

Trying to run my maven project for testing UI in android application. To prepare execution I need to run appium and run emulator. I can do all this on my local env from bash script. As project is on github I would like to use travis. This is appium/selenium/testng/java project. I’m not sure if I have .travis.yml with “language: android” or should I start with “language: java”. Anyway all components I install success but when I want to execute android sdk manager I can see this:

env:
    global:
        - ANDROID_API_LEVEL=28
        - ANDROID_BUILD_TOOLS_VERSION=28.0.3
        - ANDROID_ABI=armeabi-v7a

android:
    components:
        - tools
        - platform-tools
        - tools
        - extra-android-m2repository
    licenses:
        - 'android-sdk-preview-license-52d11cd2'
        - 'android-sdk-license-.+'
        - 'google-gdk-license-.+'

and this output

Setting environment variables from .travis.yml

$ export ANDROID_API_LEVEL=28

$ export ANDROID_BUILD_TOOLS_VERSION=28.0.3

$ export ANDROID_ABI=armeabi-v7a

Installing Android dependencies

0.13s$ android-update-sdk --components=tools --accept-licenses='android-sdk-preview-license-52d11cd2|android-sdk-license-.+|google-gdk-license-.+'

android-update-sdk: command not found

The command "android-update-sdk --components=tools --accept-licenses='android-sdk-preview-license-52d11cd2|android-sdk-license-.+|google-gdk-license-.+'" failed and exited with 127 during .

I was trying user dist: trusty. Maybe I should install android sdk, not sure because I did not see if anyone installing sdk

Regards

Solution I have found was replace:

language: android to language: java and do android things manually :

- export ANDROID_HOME=~/android-sdk-linux
- wget -q "https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip" -O android-sdk-tools.zip
- unzip -q android-sdk-tools.zip -d ${ANDROID_HOME}
- rm android-sdk-tools.zip
- PATH=${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/tools/bin:${ANDROID_HOME}/platform-tools
- mkdir -p ~/.android
- touch ~/.android/repositories.cfg
- yes | sdkmanager --licenses
- yes | sdkmanager "emulator" "tools" "platform-tools" > /dev/null
- yes | sdkmanager "platforms;android-25" > /dev/null
- yes | sdkmanager "build-tools;25.0.2" > /dev/null
- yes | sdkmanager "system-images;android-25;google_apis;armeabi-v7a" > /dev/null
/dev/null

I’m seeing this today as well. This is new, I just updated a dependency and now all my builds are failing. Is the java manual approach the only fix?

Here’s my travis config:

if: branch = master

language: android

before_cache:
  - rm -f  $HOME/.gradle/caches/modules-2/modules-2.lock
  - rm -fr $HOME/.gradle/caches/*/plugin-resolution/
cache:
  directories:
    - $HOME/.gradle/caches/
    - $HOME/.gradle/wrapper/
    # Android build cache (see https://developer.android.com/studio/build/build-cache.html)
    - $HOME/.android/build-cache

android:
  components:
    - tools
    - platform-tools
    - tools
    - extra-android-m2repository

    # The BuildTools version used by your project
    - build-tools-28.0.3

    # The SDK version used to compile your project
    - android-28

licenses:
    - 'android-sdk-license-.+'

before_install:
  - yes | sdkmanager "platforms;android-28"
  - yes | sdkmanager "emulator" "tools" "platform-tools"
  - yes | sdkmanager --licenses
  - yes | sdkmanager "build-tools;28.0.3"

@stowy WFM.

Please link to the build, can’t say more otherwise.

For starters, since the built-in logic installs all the components specified under android: components:

  • I see no purpose in the before_install: section
  • neither for calling android-update-sdk at any point

The Android recipes/cookbook is desperately old and seemingly not maintained at the moment.

My advice is to manually set-up the sdkmanager CLI and let the Android Gradle plugin automatically download all nessesary dependencies. This feature is supported starting from Android Gradle 3.3 (https://developer.android.com/studio/intro/update#download-with-gradle). So it’s even easier than what @karcio described (you don’t need to tell Travis CI the SDK Plattform or Build Tools Version).

You can even use the language: minimal since it ships Java 8 to get the fastest possible boot times:

language: minimal
os: linux
dist: xenial
group: edge

env:
  global:
  # for updates check developer.android.com/studio#downloads (current 26.1.1)
  - ANDROID_SDK_TOOLS=sdk-tools-linux-4333796.zip

before_install:
  # set JAVA_HOME path
  - export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
  # download and unzip Android SDK command line tools
  - wget -nv https://dl.google.com/android/repository/$ANDROID_SDK_TOOLS
  - unzip -q $ANDROID_SDK_TOOLS -d $HOME/sdk
  # set SDK tools path variable and ANDROID_HOME
  - export PATH=$PATH:$HOME/sdk/tools/bin
  - export ANDROID_HOME=$HOME/sdk
  # create empty cfg file to prevent sdkmanager warning message
  - mkdir -p $HOME/.android && touch $HOME/.android/repositories.cfg
install:
  # accept licenses for all available packages that have not already been accepted
  - yes | sdkmanager --licenses >/dev/null
before_script:
  # set executable flag for gradle wrapper
  - chmod +x gradlew
  # create dir for gradle settings
  - mkdir -p $HOME/.gradle
  # disable gradle daemon for current user
  - echo "org.gradle.daemon=false" >> $HOME/.gradle/gradle.properties
  # set gradle log format to plain
  - echo "org.gradle.console=plain" >> $HOME/.gradle/gradle.properties
1 Like

Thanks @native-api. Here’s a build. I added the license accepting bit to fix an earlier issue. I’m not calling ‘android-update-sdk’ myself.

My build config also stopped working in the last days. Travis support estimated, that my machine got migrated to xenial ( i had no dist set). after adding “dist: trusty” the enviromant hat a working android-update-sdk again.

Seems like all examples linked at docs are outdated, because none of them got dist set correct. At least its mentioned at https://docs.travis-ci.com/user/languages/android/

This example works today: https://github.com/Codeuctivity/BonReaderIonic/blob/master/.travis.yml

thanks to Dominic Jodoin from travis support team

@stowy the build you linked to is all cancelled with no logs and I don’t see any relevant failures in other recent builds.

Testing dist: xenial does show the subj error. So adding dist: trusty should fix it. In the tests, I never got xenial when I omitted dist: with language: android but I guess this happens randomly.

Thanks @native-api again! I have currently migrated to @G00fY2’s solution which works for me, but if I can make some changes to make the android solution work again then I’ll test that out. :slight_smile:

The language: android cookbook has not been updated for more than 2 years and still has preinstalled SDK Tools, Build-Tools and SDK Version 25: android-sdk version 0.2.2

I don’t see much sense in sticking with that when you have to update all dependencies anyway and are forced to use an old distribution.

Also the components like extra-google-google_play_services, extra-google-m2repository and extra-android-m2repository are outdated/unnecessary, since Google moved the dependencies to their own Google Maven servers (the google() repository in your build.gradle).

Hi All, my builds are failing as of a few days ago despite having had only changed something totally unrelated to any dependency updates.

This build fails (only a trivial change to a JSON object): https://github.com/AlphaWallet/alpha-wallet-android/commit/316bab1a47038cb5b08467e65a81bddeb7b01a84

Build config: https://github.com/AlphaWallet/alpha-wallet-android/blob/master/.travis.yml

But the previous commit passed: https://github.com/AlphaWallet/alpha-wallet-android/commit/47eb0068eedcfaf41cd2118e8a04ca7a2638a610

The only thing that changed was this JSON object.

https://api.travis-ci.com/v3/job/221092290/log.txt

Edit: working now all of a sudden :slight_smile:

Imprint