Getting incompatible AVD error while running instrumentation test


I am getting below error whenever I am trying to run instrumentation test for my android project :

Skipping device 'test(AVD)' for 'app:': Unknown API Level

 > : No compatible devices connected.[TestRunner] FAILED 
Found 1 connected device(s), 0 of which were compatible.
:app:connectedDebugAndroidTest FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:connectedDebugAndroidTest'.
> There were failing tests. See the report at: file:///builds/antitheft/anti-theft-screen-lock/app/build/reports/androidTests/connected/index.html

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.


Total time: 2 mins 45.163 secs
ERROR: Job failed: exit code 1

I am using shared runner. My target API is 25 and I am trying to run the AVD on API 22.

Here is my gitlab-ci.yml file:

image: openjdk:8-jdk

  ANDROID_ABI: "armeabi-v7a"
  IS_CI_BUILD : "true"

  - apt-get --quiet update --yes
  - apt-get --quiet install --yes wget tar unzip lib32stdc++6 lib32z1
  - wget --quiet --output-document=android-sdk.tgz${ANDROID_SDK_TOOLS}-linux.tgz
  - tar --extract --gzip --file=android-sdk.tgz
  - echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter android-${ANDROID_COMPILE_SDK}
  - echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter android-${ANDROID_TEST_SDK}
  - echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter platform-tools
  - echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter build-tools-${ANDROID_BUILD_TOOLS}
  - echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter extra-android-m2repository
  - echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter extra-google-google_play_services
  - echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter extra-google-m2repository
  - export ANDROID_HOME=$PWD/android-sdk-linux
  - export PATH=$PATH:$PWD/android-sdk-linux/platform-tools/
  - chmod +x ./gradlew

  - build   #Generates the release and debug build
  - test    #Performs unit and insttrumentation tests.

debugBuild:   #Generate debug build for dev and master branch
  stage: build
    - ./gradlew assembleDebug
    - master
    - dev
    - app/build/outputs/

unitTests:  #Unit tests
  stage: test
    #Run the unit test
    - ./gradlew test

functionalTests:  #Instrumantation tests
  stage: test
     #Download the wait for emulator script
    - wget --quiet --output-document=android-wait-for-emulator
    - chmod +x android-wait-for-emulator

    #Download emulator image for armeabi-v7a
    - echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter sys-img-armeabi-v7a-google_apis-${ANDROID_TEST_SDK}

    #Create AVD
    - echo no | android-sdk-linux/tools/android create avd --force -n test -t android-${ANDROID_TEST_SDK} --abi google_apis/armeabi-v7a

    #Start the AVD and wait for the emulator to start
    - android-sdk-linux/tools/emulator64-arm -avd test -no-audio -no-window &
    - ./android-wait-for-emulator

    #Display list of devices
    - adb devices

    #Unloack device and run the instrumantation test
    - adb shell input keyevent 82 &
    - ./gradlew connectedAndroidTest

Help me with resolving this issue. I am trying to run it for last 4-5 days with no luck.

Thank you.


I am facing the same issue with a similar configuration. @kevalpatel2106 Did you manage to find a solution?


Even though this topic is already open for a long time, I ran into the same problem and want to share my solution.

First of all, in the current android sdk, the android executable is deprecated. Try using android-sdk-linux/tools/bin/sdkmanager (see this post for more in-depth explanations).

Even though I don’t know the exact reason, the ARM architecture is not compatible with GitLab Runners. I assume they run on an emulated Intel core or sth. (only speculation and no real background knowledge on my side).

Another problem is, that the x86 images require KVM hardware acceleration. Currently, that is not supported from every shared runner. The runners with the do-tag do support KVM though. The following code worked for me (no extra kvm installations or configurations needed):

    - ../linux-sdk-tools/tools/bin/sdkmanager "system-images;android-${ANDROID_COMPILE_SDK};google_apis;x86"
    - echo no | ../linux-sdk-tools/tools/bin/avdmanager create avd -n testAVD -k "system-images;android-${ANDROID_COMPILE_SDK};google_apis;x86"
    - ../linux-sdk-tools/tools/emulator -avd testAVD -no-audio -no-window &
    - ./android-wait-for-emulator

Hope that helps everyone stumbling about this.


do tag is not available and now listed in shared-runners list. May be this can be a solution