Instrumented tests with an emulator for an Android App project - KVM support problem

I want to run a pipeline that includes android app instrumented tests, which require an android emulator.

I am using the image:

(from GPU-enabled hosted runners | GitLab)

I want an image that will allow me to run android emulator which requires hardward acceleration.

Although I have installed KVM, when I run


I am getting the error:

INFO: Your CPU does not support KVM extensions
KVM acceleration can NOT be used

What do I need to do to fix this?

This is my .gitlab-ci.yml file:

image: eclipse-temurin:17-jdk-jammy


  # ANDROID_COMPILE_SDK is the version of Android you're compiling with.
  # It should match compileSdkVersion.

  # It's what version of the command line tools we're going to download from the official site.
  # Official Site->
  # There, look down below at the cli tools only, sdk tools package is of format:
  # when the script was last modified for latest compileSdkVersion, it was which is written down below
  ANDROID_SDK_TOOLS: "11076708"
  GRADLE_OPTS: "-Dorg.gradle.daemon=false"
  EMULATOR_IMAGE: "android-34;default;x86_64"

# Packages installation before running script
  - apt-get --quiet update --yes
  - apt-get --quiet install --yes wget unzip

  # install JAVA
  - apt install --yes openjdk-17-jdk
  - echo "export JAVA_HOME=$(dirname $(dirname $(readlink -f $(which java))))" >> ~/.bashrc
  - source ~/.bashrc

  # Setup path as android_home for moving/exporting the downloaded sdk into it
  - export ANDROID_HOME="${PWD}/android-sdk-root"
  # Create a new directory at specified location
  - install -d $ANDROID_HOME
  # Here we are installing androidSDK tools from official source,
  # (the key thing here is the url from where you are downloading these sdk tool for command line, so please do note this url pattern there and here as well)
  # after that unzipping those tools and
  # then running a series of SDK manager commands to install necessary android SDK packages that'll allow the app to build
  - wget --no-verbose --output-document=$ANDROID_HOME/${ANDROID_SDK_TOOLS}
  - unzip -q -d "$ANDROID_HOME/cmdline-tools" "$ANDROID_HOME/"
  - mv -T "$ANDROID_HOME/cmdline-tools/cmdline-tools" "$ANDROID_HOME/cmdline-tools/tools"
  - export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/cmdline-tools/tools/bin:$ANDROID_HOME/platform-tools:$ANDROID_HOME/emulator

  # Nothing fancy here, just checking sdkManager version
  - sdkmanager --version

  # use yes to accept all licenses
  - yes | sdkmanager --licenses > /dev/null || true
  - sdkmanager --update
  - sdkmanager "platforms;android-${ANDROID_COMPILE_SDK}"
  - sdkmanager "platform-tools"
  - sdkmanager "build-tools;${ANDROID_COMPILE_SDK}.0.0"

  # Not necessary, but just for surity
  - chmod +x ./gradlew

  - test

# Run all tests, if any fails, interrupt the pipeline(fail it)
# Currently commented out, because I can't make the emulator run
# I am facing the same problem that it is described here:
  interruptible: true
  stage: test
    - saas-linux-medium-amd64-gpu-standard
  image: mixlrdev/nvcr-io-nvidia-cuda-12-1-1-base-ubuntu22-04-kvm:latest
    # install packages needed by emulator
    - apt-get install libx11-dev libpulse0 libgl1 libnss3 libxcomposite-dev libxcursor1 libasound2 --yes

    # install android sdk components and emulator
    - sdkmanager "emulator" "system-images;${EMULATOR_IMAGE}"

    # download script for emulator waiting
    - wget --quiet --output-document=android-wait-for-emulator
    - chmod +x android-wait-for-emulator

    # create virtual device named "test"
    - echo no | avdmanager -v create avd -n test -k "system-images;${EMULATOR_IMAGE}"

    # start adb server
    - adb start-server
    - echo "KVM support?"
    - kvm-ok

    # run emulator and tests
    - emulator -avd test -no-boot-anim -no-window -no-audio -no-snapshot -gpu auto &
    - ./android-wait-for-emulator

    - ./gradlew -Pci --console=plain connectedAndroidTest

    when: always
      - 'app/build/reports/'

  interruptible: true
  stage: test
    - ./gradlew -Pci --console=plain test
    when: always
      - '**/build/reports/'

The mixlrdev/nvcr-io-nvidia-cuda-12-1-1-base-ubuntu22-04-kvm:latest is built with the following Dockerfile:


# Install necessary packages
RUN apt-get update && \
    apt-get install -y qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils kmod virt-manager && \
    groupadd kvm && \

# Ensure libvirtd is started
RUN systemctl enable libvirtd

# Expose necessary ports
EXPOSE 5900 16509

# Start libvirtd
CMD ["/sbin/init"]

It seems like a long pending issue. Running Android emulator in Gitlab provided runners seems still not resolved.