0

I'm working on an Android app hosted on Azure Devops. We have complete CI/CD setup over there. I wanted to create a new pipeline to run UI tests on an AVD but I can't seem to figure it out. The pipeline I created is very simple, it first runs the script to create an AVD image then runs that image on the emulator

- task: Bash@3
  inputs:
    targetType: 'inline'
    script: |
      #!/usr/bin/env bash

      # Install AVD files
      echo "y" | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --install 'system-images;android-35;google_apis;x86_64'

      # Create emulator
      echo "y" | $ANDROID_HOME/cmdline-tools/latest/bin/avdmanager create avd -n android_emulator -d "pixel" -k 'system-images;android-35;google_apis;x86_64' --force

      echo "y" | $ANDROID_HOME/emulator/emulator -list-avds

      echo "Starting emulator"

      # Start emulator in background
      nohup $ANDROID_HOME/emulator/emulator -avd android_emulator -no-snapshot -no-window -no-audio -no-boot-anim -accel on > /dev/null 2>&1 &
      
      $ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d "\r") ]]; do sleep 1; done; input keyevent 82'

      $ANDROID_HOME/platform-tools/adb devices

      echo "Emulator started"

And the next step would be simply to run the UI tests on the running emulator and publish the results

steps:
  - task: Gradle@4
    inputs:
      workingDirectory: ''
      gradleWrapperFile: 'gradlew'
      gradleOptions: '-Xmx3072m'
      publishJUnitResults: false
      testResultsFiles: '**/TEST-*.xml'
      tasks: 'connectedStagingDebugAndroidTest'

The problem is the first script gets stuck trying to start the emulator after printing "Starting emulator" even though I'm using the macOS-latest vmImage in the pipeline. Am I missing something? what might be the cause that the emulator doesn't start? and how can I know more information about the errors happening?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.