yorickvanzweeden / android-ci

A docker image for building Android apps with AVD for API Level 24
MIT License
18 stars 10 forks source link

Figure out how it should work #3

Open MisterFruits opened 5 years ago

MisterFruits commented 5 years ago

I'm really interested with your mechanism that allow running android connect tests on CI (it's heartbreaking to see implemented tests not running).

Problem is I'm pretty new to android/docker programmation and I can't get your script running on my public Gitlab account:

I gathered all your ci scrip in one (just correcting the location of the android-wait-for-emulator):

test:instrumented:debug:
  image: yorickvanzweeden/android-ci:latest
  before_script:
    - export GRADLE_USER_HOME=`pwd`/.gradle
    - chmod +x ./gradlew
  stage: test
  only:
    - 18-follow-up-on-running-ui-tests-on-gitlab-ci
  script:
    # Running emulator
    - /sdk/emulator/emulator -avd ${AVD_NAME} -no-window -no-audio -snapshot ${SNAPSHOT_NAME} &

    # Wait for emulator
    - /android-wait-for-emulator

    # Run instrumented Android tests
    - /sdk/platform-tools/adb shell input keyevent 82
    - ./gradlew cAT

But I still face the error

emulator: ERROR: x86_64 emulation currently requires hardware acceleration!
Please ensure KVM is properly installed and usable.
CPU acceleration status: KVM requires a CPU that supports vmx or svm
Waiting for emulator to start
No emulators were found

Can you say what did I do wrong ? I also saw !2 would you recommend basing my work on this branch ?

Cheers

yorickvanzweeden commented 5 years ago

Hey @MisterFruits,

This means that KVM was installed, but not supported. KVM is virtualization software that is used to run Qemu (emulation software). Either your CPU does not support virtualization, or it is disabled in the bios. Go into your bios and see if you can find a setting to enable it.

Additionally, you can use kvm-ok to find out more, as described here. The Android team has a page about it as well.

If you lack support for virtualization, you can try to use ARM instead of x86. It will be significantly slower, but it may be worth the costs. You should edit packages.txt and add the package for the ARM emulator. I'm not entirely sure what it's called, but you can the SDK manager to list all downloadable packages. This would be your last resort option. Fixing KVM will probably be easier

PR !2 was used for an old computer that seemed unable to properly load a snapshot. We were able to load the snapshot from a booting emulator rather than from the command line.

sampalmer commented 3 years ago

I'm getting the same error. Is this image designed to be used on a custom GitLab runner that's been manually configured to support hardware acceleration? I'm running it on a GitLab shared runner and getting the same error as the one here.

yorickvanzweeden commented 3 years ago

@sampalmer If you want to run an emulator, you need to have KVM available on your Gitlab runner. This may take some preparations. I ran it on a PC with virtualization enabled