mreichelt / docker-android

Docker images for Android development
MIT License
74 stars 11 forks source link

Support for Instrumented tests #19

Open eugenio1590 opened 4 years ago

eugenio1590 commented 4 years ago

I am using this docker to run the unit tests in an android project. It is worked very well. But I need support to run the expresso tests with that docker.

Currently, I have three steps for doing it:

  1. Install KVM (I am not sure about this steps)

    - apt-get --quiet install --yes libx11-dev libpulse0 libgl1 libnss3 libxcomposite-dev libxcursor1 libasound2
    - apt-get --quiet install --yes qemu-kvm libvirt-daemon-system libvirt-dev libvirt-clients virtinst bridge-utils
  2. Get the android-wait-for-emulator

    - wget --quiet --output-document=android-wait-for-emulator https://raw.githubusercontent.com/travis-ci/travis-cookbooks/0f497eb71291b52a703143c5cd63a217c8766dc9/community-cookbooks/android-sdk/files/default/android-wait-for-emulator
    - chmod +x android-wait-for-emulator
  3. Create the emulator and wait for it to be ready to run the tests.

    - echo no | android-sdk-linux/tools/bin/avdmanager create avd -n test -k "system-images;android-${ANDROID_EMULATOR_VERSION};google_apis;x86"
    - android-sdk-linux/emulator/emulator -avd test -accel auto -gpu auto -no-window -no-audio &
    - ./android-wait-for-emulator
    - adb shell input keyevent 82
Syne10 commented 4 years ago

were you able to solve the problem?

eugenio1590 commented 4 years ago

were you able to solve the problem?

I am sorry but I couldn't resolve it.

mreichelt commented 3 years ago

Hey @eugenio1590! This issue has been open for quite a while, and I'm sorry that I didn't respond for so long. I'm trying to figure out what your actual need is here.

The script android-wait-for-emulator already is included in all of these images, as is at least one system image in the xx-system variants: https://github.com/mreichelt/docker-android/blob/master/minimal.Dockerfile#L20-L22

And as far as I remember, I actually set everything up in the images for the emulators to be run successfully.

What is missing for you to be able to start the emulator?

As far as I know, KVM actually has to be installed on the Linux host machine (rather than the Docker guest), and the /dev/kvm device has to be mounted into the guest from the outside for the emulator to actually work. This thread on StackOverflow describes how.

I'd love to know how I can help!