Android emulator out of date

I’m trying to setup my project to run tests on an emulator. However I’m getting an error that the emulator is out of date.

Here’s the error log from the Launch emulator task that is failing:

WARNING | Failed to process .ini file /home/circleci/.android/emu-update-last-check.ini for reading.
INFO | Your emulator is out of date, please update by launching Android Studio:

  • Start Android Studio
  • Select menu “Tools > Android > SDK Manager”
  • Click “SDK Tools” tab
  • Check “Android Emulator” checkbox
  • Click “OK”
    WARNING | Failed to process .ini file /home/circleci/.android/emu-update-last-check.ini for reading.

Here is my job in the config.yml:

working_directory: ~/app
name: android/android-machine
resource-class: large
tag: 2023.07.1
- checkout
# Download and setup the Android SDK
- run:
name: Download Android SDK
command: |
curl redacted_because_I_cant_add_links_in_posts/android/repository/ --output
unzip -qq -d android-sdk-linux
echo y | android-sdk-linux/cmdline-tools/bin/sdkmanager --sdk_root=$ANDROID_HOME --licenses
echo y | android-sdk-linux/cmdline-tools/bin/sdkmanager --sdk_root=$ANDROID_HOME “platforms;android-30”
echo y | android-sdk-linux/cmdline-tools/bin/sdkmanager --sdk_root=$ANDROID_HOME “build-tools;30.0.3”

  # Create the emulator
  - run:
      name: Create emulator
      command: |
        sdkmanager "$SYSTEM_IMAGES"
        echo "no" | avdmanager --verbose create avd -n test -k "$SYSTEM_IMAGES"
  - run:
      name: Update emulator
      command: |
        sdkmanager "emulator" # Update the emulator using the SDK manager
  # Start the emulator
  - run:
      name: Launch emulator
      command: |
        emulator -avd test -delay-adb -verbose -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim
      background: true
  # Set up caching for future builds
  - run:
      name: Generate cache key
      command: |
        find . -name 'build.gradle' | sort | xargs cat |
        shasum | awk '{print $1}' > /tmp/gradle_cache_seed
  - restore_cache:
      key: gradle-v1-{{ arch }}-{{ checksum "/tmp/gradle_cache_seed" }}
  # Build the app
  - run:
      # run in parallel with the emulator starting up, to optimize build time
      name: Run assembleDebugAndroidTest task
      command: |
        ./gradlew assembleDebugAndroidTest
  - run:
      name: Wait for emulator to start
      command: |
        circle-android wait-for-boot
  - run:
      name: Disable emulator animations
      command: |
        adb shell settings put global window_animation_scale 0.0
        adb shell settings put global transition_animation_scale 0.0
        adb shell settings put global animator_duration_scale 0.0
  - run:
      name: Run UI tests (with retry)
      command: |
        run_with_retry() {
           until [ $n -gt $MAX_TRIES ]
              echo "Starting test attempt $n"
              ./gradlew connectedDebugAndroidTest && break
              sleep 5
           if [ $n -gt $MAX_TRIES ]; then
             echo "Max tries reached ($MAX_TRIES)"
             exit 1
  - save_cache:
      key: gradle-v1-{{ arch }}-{{ checksum "/tmp/gradle_cache_seed" }}
        - ~/.gradle/caches
        - ~/.gradle/wrapper

Are you aware of the circleci/android@2.3.0 ORB?

This is a pre-defined set of commands to allow an Android environment to be defined and is designed to work alongside the Android image.

While you do not have to use it, it is worth looking at.