Coder Social home page Coder Social logo

reactivecircus / android-emulator-runner Goto Github PK

View Code? Open in Web Editor NEW
898.0 12.0 178.0 2.06 MB

A GitHub Action for installing, configuring and running hardware-accelerated Android Emulators on macOS virtual machines.

License: Apache License 2.0

TypeScript 49.53% JavaScript 49.02% Kotlin 1.44%
android-emulators github-actions testing ci

android-emulator-runner's Introduction

GitHub Action - Android Emulator Runner

GitHub Actions status

A GitHub Action for installing, configuring and running hardware-accelerated Android Emulators on Linux and macOS virtual machines.

The old ARM-based emulators were slow and are no longer supported by Google. The modern Intel Atom (x86 and x86_64) emulators can be fast, but rely on two forms of hardware acceleration to reach their peak potential: Graphics Acceleration, e.g. emulator -gpu host and Virtual Machine(VM) Acceleration, e.g. emulator -accel on. Note: GPU and VM Acceleration are two different and non-mutually exclusive forms of Hardware Acceleration.

This presents a challenge when running emulators on CI especially when running emulators within a docker container, because Nested Virtualization must be supported by the host VM which isn't the case for most cloud-based CI providers due to infrastructural limits. If you want to learn more about Emulators on CI, here's an article Yang wrote: Running Android Instrumented Tests on CI.

Running hardware accelerated emulators on Linux runners

GitHub's larger Linux runners support running hardware accelerated emulators which is free for public GitHub repos. It is now recommended to use the Ubuntu (ubuntu-latest) runners which are 2-3 times faster than the macOS ones which are also a lot more expensive. Remember to enable KVM in your workflow before running this action:

- name: Enable KVM group perms
  run: |
    echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
    sudo udevadm control --reload-rules
    sudo udevadm trigger --name-match=kvm

A note on VM Acceleration and why we don't need HAXM anymore

According to this documentation, "on Mac OS X v10.10 Yosemite and higher, the Android Emulator uses the built-in Hypervisor.Framework by default, and falls back to using Intel HAXM if Hypervisor.Framework fails to initialize." This means that HAXM is only needed to achieve VM Acceleration if this default Hypervisor is not available on macOS machines.

Note: Manually enabling and downloading HAXM is not recommended because it is redundant and not needed (see above), and for users of macOS 10.13 High Sierra and higher: macOS 10.13 disables installation of kernel extensions by default. Because Intel HAXM is a kernel extension, we would need to manually enable its installation on the base runner VM. Furthermore, manually trying to install HAXM on a Github Runner brings up a popup which further hinders tests from running.

Purpose

This action helps automate and configure the process of setting up an emulator and running your tests by doing the following:

  • Install / update the required Android SDK components including build-tools, platform-tools, platform (for the required API level), emulator and system-images (for the required API level).
  • Create a new instance of AVD with the provided configurations.
  • Launch a new Emulator with the provided configurations.
  • Wait until the Emulator is booted and ready for use.
  • Run a custom script provided by user once the Emulator is up and running - e.g. ./gradlew connectedCheck.
  • Kill the Emulator and finish the action.

Usage & Examples

A workflow that uses android-emulator-runner to run your instrumented tests on API 29:

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - name: checkout
        uses: actions/checkout@v4

      - name: Enable KVM
        run: |
          echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
          sudo udevadm control --reload-rules
          sudo udevadm trigger --name-match=kvm

      - name: run tests
        uses: reactivecircus/android-emulator-runner@v2
        with:
          api-level: 29
          script: ./gradlew connectedCheck

We can also leverage GitHub Actions's build matrix to test across multiple configurations:

jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        api-level: [21, 23, 29]
        target: [default, google_apis]
    steps:
      - name: checkout
        uses: actions/checkout@v4

      - name: Enable KVM
        run: |
          echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
          sudo udevadm control --reload-rules
          sudo udevadm trigger --name-match=kvm

      - name: run tests
        uses: reactivecircus/android-emulator-runner@v2
        with:
          api-level: ${{ matrix.api-level }}
          target: ${{ matrix.target }}
          arch: x86_64
          profile: Nexus 6
          script: ./gradlew connectedCheck

If you need specific versions of NDK and CMake installed:

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - name: checkout
        uses: actions/checkout@v4

      - name: Enable KVM
        run: |
          echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
          sudo udevadm control --reload-rules
          sudo udevadm trigger --name-match=kvm

      - name: run tests
        uses: reactivecircus/android-emulator-runner@v2
        with:
          api-level: 29
          ndk: 21.0.6113669
          cmake: 3.10.2.4988404
          script: ./gradlew connectedCheck

We can significantly reduce emulator startup time by setting up AVD snapshot caching:

  1. add a gradle/actions/setup-gradle@v3 step for caching Gradle, more details see #229
  2. add an actions/cache@v4 step for caching the avd
  3. add a reactivecircus/android-emulator-runner@v2 step to generate a clean snapshot - specify emulator-options without no-snapshot
  4. add another reactivecircus/android-emulator-runner@v2 step to run your tests using existing AVD / snapshot - specify emulator-options with no-snapshot-save
jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        api-level: [21, 23, 29]
    steps:
      - name: checkout
        uses: actions/checkout@v4

      - name: Enable KVM
        run: |
          echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
          sudo udevadm control --reload-rules
          sudo udevadm trigger --name-match=kvm

      - name: Gradle cache
        uses: gradle/actions/setup-gradle@v3
        
      - name: AVD cache
        uses: actions/cache@v4
        id: avd-cache
        with:
          path: |
            ~/.android/avd/*
            ~/.android/adb*
          key: avd-${{ matrix.api-level }}

      - name: create AVD and generate snapshot for caching
        if: steps.avd-cache.outputs.cache-hit != 'true'
        uses: reactivecircus/android-emulator-runner@v2
        with:
          api-level: ${{ matrix.api-level }}
          force-avd-creation: false
          emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
          disable-animations: false
          script: echo "Generated AVD snapshot for caching."

      - name: run tests
        uses: reactivecircus/android-emulator-runner@v2
        with:
          api-level: ${{ matrix.api-level }}
          force-avd-creation: false
          emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
          disable-animations: true
          script: ./gradlew connectedCheck

Configurations

Input Required Default Description
api-level Required N/A API level of the platform system image - e.g. 23 for Android Marshmallow, 29 for Android 10. Minimum API level supported is 15.
target Optional default Target of the system image - default, google_apis, playstore, android-wear, android-wear-cn, android-tv, google-tv, aosp_atd or google_atd. Note that aosp_atd and google_atd currently require the following: api-level: 30, arch: x86 or arch: arm64-v8 and channel: canary.
arch Optional x86 CPU architecture of the system image - x86, x86_64 or arm64-v8a. Note that x86_64 image is only available for API 21+. arm64-v8a images require Android 4.2+ and are limited to fewer API levels (e.g. 30).
profile Optional N/A Hardware profile used for creating the AVD - e.g. Nexus 6. For a list of all profiles available, run avdmanager list device.
cores Optional 2 Number of cores to use for the emulator (hw.cpu.ncore in config.ini).
ram-size Optional N/A Size of RAM to use for this AVD, in KB or MB, denoted with K or M. - e.g. 2048M
heap-size Optional N/A Heap size to use for this AVD, in KB or MB, denoted with K or M. - e.g. 512M
sdcard-path-or-size Optional N/A Path to the SD card image for this AVD or the size of a new SD card image to create for this AVD, in KB or MB, denoted with K or M. - e.g. path/to/sdcard, or 1000M.
disk-size Optional N/A Disk size, or partition size to use for this AVD. Either in bytes or KB, MB or GB, when denoted with K, M or G. - e.g. 2048M
avd-name Optional test Custom AVD name used for creating the Android Virtual Device.
force-avd-creation Optional true Whether to force create the AVD by overwriting an existing AVD with the same name as avd-name - true or false.
emulator-boot-timeout Optional 600 Emulator boot timeout in seconds. If it takes longer to boot, the action would fail - e.g. 300 for 5 minutes.
emulator-options Optional See below Command-line options used when launching the emulator (replacing all default options) - e.g. -no-window -no-snapshot -camera-back emulated.
disable-animations Optional true Whether to disable animations - true or false.
disable-spellchecker Optional false Whether to disable spellchecker - true or false.
disable-linux-hw-accel Optional auto Whether to disable hardware acceleration on Linux machines - true, false or auto.
enable-hw-keyboard Optional false Whether to enable hardware keyboard - true or false.
emulator-build Optional N/A Build number of a specific version of the emulator binary to use e.g. 6061023 for emulator v29.3.0.0.
working-directory Optional ./ A custom working directory - e.g. ./android if your root Gradle project is under the ./android sub-directory within your repository. Will be used for script & pre-emulator-launch-script.
ndk Optional N/A Version of NDK to install - e.g. 21.0.6113669
cmake Optional N/A Version of CMake to install - e.g. 3.10.2.4988404
channel Optional stable Channel to download the SDK components from - stable, beta, dev, canary
script Required N/A Custom script to run - e.g. to run Android instrumented tests on the emulator: ./gradlew connectedCheck
pre-emulator-launch-script Optional N/A Custom script to run after creating the AVD and before launching the emulator - e.g. ./adjust-emulator-configs.sh

Default emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim.

Who is using Android Emulator Runner?

These are some of the open-source projects using (or used) Android Emulator Runner:

If you are using Android Emulator Runner and want your project included in the list, please feel free to open a pull request.

android-emulator-runner's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-emulator-runner's Issues

Emulator get killed after running script

Hi @ychescale9, I actually don't know what's run but any time I use your action it kills the emulator after booting

    - name: Setup android emulator of drive test
      uses: ReactiveCircus/[email protected]
      with:
        api-level: 29
        script: flutter devices
Emulator booted.
adb shell input keyevent 82
Disabling animations.
adb shell settings put global window_animation_scale 0.0
adb shell settings put global transition_animation_scale 0.0
adb shell settings put global animator_duration_scale 0.0
sh -c \flutter devices
emulator: INFO: boot completed
emulator: INFO: boot time 52579 ms
emulator: Increasing screen off timeout, logcat buffer size to 2M.
emulator: Revoking microphone permissions for Google App.
1 connected device:

Android SDK built for x86 • emulator-5554 • android-x86 • Android 10 (API 29) (emulator)
adb -s emulator-5554 emu kill
OK: killing emulator, bye bye
OK
emulator: Discarding the changed state: command-line flag
emulator: WARNING: Discarding the changed state (command-line flag).

AVD launch options

Hi @ychescale9 , thanks for your work! I'd love to have more control over the emulator launch options. Any chance of making them configurable?

        with:
          api-level: ...
          emulator-options: -no-snapshot -camera-back emulated
          script: ...

If not specified, it could default to what you currently have: -no-snapshot -noaudio -no-boot-anim . I can probably set up a PR if you want.

Support Custom System Images

I was wondering if there is / will be support for emulators running custom system images? For example, if I had gotten the system image directly from a manufacturer it would be awesome to be able to use this to test my application(s) on the device without actually needing the hardware.

It would also be really useful for rooted images as well.

sh: ./gradlew: No such file or directory

sh -c ./gradlew connectedCheck
sh: ./gradlew: No such file or directory
##[error]The process 'sh' failed with exit code 127
adb -s emulator-5554 emu kill
OK: killing emulator, bye bye
OK
emulator: Discarding the changed state: command-line flag
emulator: WARNING: Discarding the changed state (command-line flag).

No connected devices

Hi, I'm running an issue where this action fails due to com.android.builder.testing.api.DeviceException: No connected devices!. It seems to have started around the same time as the 2.1 release. Here's an example where it's failing. Let me know if I can help debug the issue.

Failed to find package "system-images;android-28;google_apis;x86"

The issue is happening because Android SDK repositories are missing this particular emulator image. The SDK repos have following images for android-28

system-images;android-28;android-tv;x86                                                  | 9            | Android TV Intel x86 Atom System Image                              
system-images;android-28;android-wear-cn;x86                                             | 3            | China version of Wear OS Intel x86 Atom System Image                
system-images;android-28;android-wear;x86                                                | 3            | Wear OS Intel x86 Atom System Image                                 
system-images;android-28;default;x86                                                     | 4            | Intel x86 Atom System Image                                         
system-images;android-28;default;x86_64                                                  | 4            | Intel x86 Atom_64 System Image                                      
system-images;android-28;google_apis;x86_64                                              | 10           | Google APIs Intel x86 Atom_64 System Image                          
system-images;android-28;google_apis_playstore;x86                                       | 9            | Google Play Intel x86 Atom System Image                             
system-images;android-28;google_apis_playstore;x86_64                                    | 8            | Google Play Intel x86 Atom_64 System Image                          
system-images;android-28;google_ndk;x86                                                  | 10           | Google X86_ARM Intel x86 Atom System Image

My workflow configuration: https://github.com/ashutoshgngwr/noice/blob/6192d19bbf5d10bd80cc52298bdf1e595860e748/.github/workflows/android.yaml#L63-L92

Failed job logs: https://github.com/ashutoshgngwr/noice/runs/755243412

Is there a suggested workaround?

How to choose emulator device?

Hello,
I can't find it in the readme, perhaps emulator-build.
I would like to specify the device, for example, Pixel 2 or Nexus 6P.

The problem is that on the emulator that is created (without specifying any configuration apart from API level 29) some elements are unexpectedly off-screen and we would need to scroll to them first, before click action.

Kind regards
Chris

Emulator doesn't find apk for installation

Hello,
I am trying to setup a pipeline using Appium + Robot framework + Android emulator to run a suite of tests headless. For this I have configured one job that takes my apk from GCS and uploads it as an artifact (no container actions yet for MacOS :( ) and then downloads it in macos runner along with installing Appium + Robot.
Issue comes when I try to execute my script against emulator. In the script option I have placed the following command:

robot --variable app:./app.apk android_happypath_1pago.robot

The pipeline output returns the following error:

sh -c \robot --variable app:./app.apk android_happypath_1pago.robot
==============================================================================
Android Happypath 1Pago :: Happy path de customer journey para Android        
==============================================================================
emulator: ### WARNING: /etc/localtime does not point to zoneinfo-compatible timezone name

Cotizacion                                                            | FAIL |
Parent suite setup failed:
WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: EISDIR: illegal operation on a directory, read
------------------------------------------------------------------------------
Contratacion                                                          | FAIL |
Parent suite setup failed:
WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: EISDIR: illegal operation on a directory, read
------------------------------------------------------------------------------
Pago                                                                  | FAIL |
Parent suite setup failed:
WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: EISDIR: illegal operation on a directory, read
------------------------------------------------------------------------------
Android Happypath 1Pago :: Happy path de customer journey para And... | FAIL |
Suite setup failed:
WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: EISDIR: illegal operation on a directory, read


3 critical tests, 0 passed, 3 failed
3 tests total, 0 passed, 3 failed
==============================================================================
Output:  /Users/runner/runners/2.165.2/work/autopilot/autopilot/output.xml
Log:     /Users/runner/runners/2.165.2/work/autopilot/autopilot/log.html
Report:  /Users/runner/runners/2.165.2/work/autopilot/autopilot/report.html
##[error]The process 'sh' failed with exit code 3
adb -s emulator-5554 emu kill
OK: killing emulator, bye bye

This seems to be a NPM issue where file is in fact a directory or is not there. I took a bit of time to read previous issues trying to find out if someone stumbled upon this before without success. At this point I am unsure whether I am doing something wrong trying to pass an apk to the emulator, if it's possible to run commands other than gradle (which should be possible according to this issue), or if I am trying to use some functionality that may not be available.
Hopefully you this info helps to describe my issue.
Thanks!

Java 9+ support

Now, using this actions with setup-java action with java 9+ failed, because sdkmanager can't run on it.
One of issues from SO
The main problem is with java 11, because there is no any solution besides not to use it.
I think, it's possible to fix it, by passing JAVA_HOME env only for installing, so gradle will work as expected

Instrumentation run failed but works well locally

Hello,

First of all, thank you for your work.

I have a clean architecture project with 3 modules (data, domain and presentation). I have instrumentals tests on both presentation and data. These tests work perfectly well locally but not with your solution. Indeed, only the data module tests work but not the presentation ones.

I tried to display more info with --info or --debug but I don't have more information.
Here is the error message:

Test failed to run to completion. Reason: 'Instrumentation run failed due to 'Process crashed.''. Check device logcat for details

Here is my configuration:

  emulator:
    name: Run Android Tests
    runs-on: macos-latest
    strategy:
      matrix:
        api-level: [21, 23, 29]
    
    steps:
    - name: Checkout
      uses: actions/checkout@v2

    - name: Run All Android Tests
      uses: reactivecircus/android-emulator-runner@v2
      with:
        api-level: ${{ matrix.api-level }}
        arch: x86_64
        profile: Nexus 6
        script: ./gradlew :presentation:connectedDebugTestAndroidTest --info

Do you have any information about what wrong here ?

allow multiple targets

It would be really nice if I could set multiple targets in 1 action.
It is possible to do w/ matrix build but when the build itself is large, running it in parallel is not great. (lots of repeated builds)

I've tried executing multiple actions but second one fails when it tries to download the command line tools:

https://github.com/ReactiveCircus/android-emulator-runner/blob/master/src/sdk-installer.ts#L16

(mkdir fails since it already exists).

I'm looking for something like this:

- name: Run Integration Tests
      uses: ReactiveCircus/[email protected]
      with:
        api-levels: [21, 24, 26, 29] 
        arch: x86_64
        script: ./gradlew connectedCheck --stacktrace

It could be even better if it invoked all emulators at once but that might overload the CI so it is fine if each one runs 1 by 1. The whole goal here is to avoid the preliminary build steps.

A possible workaround is to build the apk in 1 job and depend on its apk output in another job and run it via adb but that is also quite custom and invoking the test via gradle is still preferable.

Environment variables are unavailable in script

Hi,

When using environment variable in script, they seem to be escaped

The example below would just print $GITHUB_WORKSPACE

steps:
  - ...
  - uses: reactivecircus/android-emulator-runner@v2
    with:
      ...
      script: |
        echo $GITHUB_WORKSPACE

The problem should be around there

// execute the custom script
try {
for (const script of scripts) {
await exec.exec(`${script}`);
}
} catch (error) {
core.setFailed(error.message);
}

run adb command after Espresso test (feature request ?)

First of all, thank you for the action.

For example

  - name: Android Emulator test
    uses: ReactiveCircus/[email protected]
    with:
      api-level: 28
      disable-animations: true
      arch: x86_64
      profile: Nexus 6
      script: ./gradlew cAT

Sometimes a process crashes

Starting 0 tests on test(AVD) - 9
Tests on test(AVD) - 9 failed: Instrumentation run failed due to 'Process crashed.'

and I want to upload output of adb logcat , especial on a crash.

Does someone has a clue, how to do this ?
Or is this a simple feature request to run a custom command after action ?

Thank you

Emulator crashing?

Hello there!
First of all, congratulations on the work done on this great project.
I am facing the following problem:

- name: Connected tests uses: reactivecircus/android-emulator-runner@v2 with: api-level: 29 script: ./gradlew connectedAndroidTest

Task :connectedDefaultFlavorDebugAndroidTest Starting 12 tests on test(AVD) - 10 com.astoev.cave.survey.test.service.data.ExcelExportTest > excelExportTest[test(AVD) - 10] FAILED Test failed to run to completion. Reason: 'Test run failed to complete. Expected 12 tests, received 6'. Check device logcat for details Tests on test(AVD) - 10 failed: Test run failed to complete. Expected 12 tests, received 6. onError: commandError=false message=INSTRUMENTATION_ABORTED: System has crashed. > Task :connectedDefaultFlavorDebugAndroidTest FAILED

--------- beginning of crash 06-08 20:23:57.017 1590 1590 F libc : Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 1590 (surfaceflinger), pid 1590 (surfaceflinger)

but am still not sure what is causing it.
Do you think you can have a look? Same tests work fine locally.

Need an option to configure the build failure behavior

I configured the "strategy/matrix" as following:

    strategy:
      matrix:
        api-level: [21, 23, 29]
        target: [default, google_apis]

It's expected to start 6 builds. But if one of them is failed, the other builds will be canceled. This behavior should be configurable. In my case, I want the other builds to continue.

Support multi-line scripts

uses: reactivecircus/android-emulator-runner@v1
with:
  api-level: 29
  script: |
    ./gradlew app:connectedMockDebugAndroidTest
    ./gradlew connectedDebugAndroidTest

Option to choose emulator build version

It seems that each emulator version breaks something new. 29.3.0 was out recently (today?) and I'm now fighting against system exceptions, segmentation faults or emulator not starting at all.

It would be very nice to be able to choose a specific emulator version that proved to be "stable". See here for linux: https://github.com/mmcc007/test_emulators/blob/master/.travis.yml#L242-L245

      curl -fo emulator.zip "https://dl.google.com/android/repository/emulator-linux-$emulator_version.zip"
      rm -rf "${ANDROID_HOME}/emulator"
      unzip -q emulator.zip -d "${ANDROID_HOME}"
      rm -f emulator.zip

On macOS we should replace emulator-linux- with emulator-darwin- in the URL but it should work. This feature would let for example go back to v29.2.11.0 by passing the build number 6031357.

AdbHostServer.cpp:102: Unable to connect to adb daemon on port: 5037

I created a workflow to run emulator tests, but the actions fails.

2020-04-01T13:07:39.2101708Z ##[group]Run ReactiveCircus/[email protected]
2020-04-01T13:07:39.2101841Z with:
2020-04-01T13:07:39.2101930Z   api-level: 29
2020-04-01T13:07:39.2102022Z   script: ./gradlew :mobile:connectedFullBetaDebugAndroidTest
2020-04-01T13:07:39.2102116Z   target: default
2020-04-01T13:07:39.2102200Z   arch: x86
2020-04-01T13:07:39.2102423Z   emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim
2020-04-01T13:07:39.2102527Z   disable-animations: true
2020-04-01T13:07:39.2102598Z env:
2020-04-01T13:07:39.2102684Z   JAVA_HOME: /opt/hostedtoolcache/jdk/8.0.242/x64
2020-04-01T13:07:39.2102782Z   JAVA_HOME_8.0.242_x64: /opt/hostedtoolcache/jdk/8.0.242/x64
2020-04-01T13:07:39.2102874Z ##[endgroup]
2020-04-01T13:07:39.2448292Z You're running a Linux VM where hardware acceleration is not available. Please consider using a macOS VM instead to take advantage of native hardware acceleration support provided by HAXM.
2020-04-01T13:07:39.2453305Z API level: 29
2020-04-01T13:07:39.2453809Z target: default
2020-04-01T13:07:39.2454302Z CPU architecture: x86
2020-04-01T13:07:39.2454673Z Hardware profile: 
2020-04-01T13:07:39.2455384Z emulator options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim
2020-04-01T13:07:39.2455855Z disable animations: true
2020-04-01T13:07:39.2458159Z Script:
2020-04-01T13:07:39.2458963Z ./gradlew :mobile:connectedFullBetaDebugAndroidTest
2020-04-01T13:07:39.2472920Z Installing new cmdline-tools.
2020-04-01T13:07:39.2481419Z [command]sudo mkdir /usr/local/lib/android/sdk/cmdline-tools
2020-04-01T13:07:40.8949692Z [command]curl -fo commandlinetools.zip https://dl.google.com/android/repository/commandlinetools-linux-6200805_latest.zip
2020-04-01T13:07:40.9028610Z   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
2020-04-01T13:07:40.9029228Z                                  Dload  Upload   Total   Spent    Left  Speed
2020-04-01T13:07:40.9029663Z 
2020-04-01T13:07:41.6276794Z   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
2020-04-01T13:07:41.6808452Z  90 77.8M   90 70.6M    0     0  97.4M      0 --:--:-- --:--:-- --:--:-- 97.2M
2020-04-01T13:07:41.6808867Z 100 77.8M  100 77.8M    0     0   100M      0 --:--:-- --:--:-- --:--:--  100M
2020-04-01T13:07:41.6827213Z [command]sudo unzip -q commandlinetools.zip -d /usr/local/lib/android/sdk/cmdline-tools
2020-04-01T13:07:42.9529418Z [command]sudo rm -f commandlinetools.zip
2020-04-01T13:07:42.9720802Z [command]sh -c \sudo chmod -R 777 /usr/local/lib/android/sdk
2020-04-01T13:08:28.3521938Z [command]sh -c \echo -e '
2020-04-01T13:08:28.3523008Z 84831b9409646a918e30573bab4c9c91346d8abd' > /usr/local/lib/android/sdk/licenses/android-sdk-preview-license
2020-04-01T13:08:28.3545519Z Installing latest build tools, platform tools, and platform.
2020-04-01T13:08:28.3546819Z [command]sh -c \sdkmanager --install 'build-tools;29.0.3' platform-tools 'platforms;android-29' > /dev/null
2020-04-01T13:08:32.3740389Z Installing latest emulator.
2020-04-01T13:08:32.3741668Z [command]sh -c \sdkmanager --install emulator > /dev/null
2020-04-01T13:08:45.9361963Z Installing system images.
2020-04-01T13:08:45.9363483Z [command]sh -c \sdkmanager --install 'system-images;android-29;default;x86' > /dev/null
2020-04-01T13:09:46.5783640Z Creating AVD without custom profile.
2020-04-01T13:09:46.5785078Z [command]sh -c \echo no | avdmanager create avd --force -n test --abi 'default/x86' --package 'system-images;android-29;default;x86'
2020-04-01T13:09:47.5430343Z Loading local repository...                                                     
2020-04-01T13:09:47.5431138Z [=========                              ] 25% Loading local repository...       
2020-04-01T13:09:47.5434381Z [=========                              ] 25% Fetch remote repository...        
2020-04-01T13:09:47.5667305Z [=======================================] 100% Fetch remote repository...       
2020-04-01T13:09:47.6193576Z Do you wish to create a custom hardware profile? [no] Starting emulator.
2020-04-01T13:09:47.6198422Z [command]sh -c \/usr/local/lib/android/sdk/emulator/emulator -avd test -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -accel off &
2020-04-01T13:09:48.2743463Z emulator: ERROR: AdbHostServer.cpp:102: Unable to connect to adb daemon on port: 5037
2020-04-01T13:09:48.7085706Z emulator: WARNING: x86 emulation may not work without hardware acceleration!
2020-04-01T13:09:48.7086115Z emulator: Cold boot: requested by the user
2020-04-01T13:09:48.7086206Z Your emulator is out of date, please update by launching Android Studio:
2020-04-01T13:09:48.7086883Z  - Start Android Studio
2020-04-01T13:09:48.7087177Z  - Select menu "Tools > Android > SDK Manager"
2020-04-01T13:09:48.7087417Z  - Click "SDK Tools" tab
2020-04-01T13:09:48.7087660Z  - Check "Android Emulator" checkbox
2020-04-01T13:09:48.7087885Z  - Click "OK"
2020-04-01T13:09:48.7090116Z 
2020-04-01T13:09:57.6242289Z [command]adb shell getprop sys.boot_completed
2020-04-01T13:09:57.6268765Z * daemon not running; starting now at tcp:5037
2020-04-01T13:09:57.8401301Z * daemon started successfully
2020-04-01T13:09:57.8413034Z The process 'adb' failed with exit code 1
2020-04-01T13:09:57.8413435Z error: device offline
2020-04-01T13:09:59.8429187Z [command]adb shell getprop sys.boot_completed
2020-04-01T13:09:59.8463917Z error: device offline
2020-04-01T13:09:59.8471795Z The process 'adb' failed with exit code 1
2020-04-01T13:10:01.8500835Z [command]adb shell getprop sys.boot_completed
2020-04-01T13:10:01.8527142Z error: device offline
2020-04-01T13:10:01.8534481Z The process 'adb' failed with exit code 1
2020-04-01T13:10:03.8565701Z [command]adb shell getprop sys.boot_completed
2020-04-01T13:10:03.8595552Z error: device offline
2020-04-01T13:10:03.8604192Z The process 'adb' failed with exit code 1
2020-04-01T13:10:05.8634082Z [command]adb shell getprop sys.boot_completed
2020-04-01T13:10:05.8661082Z error: device offline
2020-04-01T13:10:05.8678987Z The process 'adb' failed with exit code 1
2020-04-01T13:10:07.8709542Z [command]adb shell getprop sys.boot_completed
2020-04-01T13:10:07.8736608Z error: device offline
2020-04-01T13:10:07.8744138Z The process 'adb' failed with exit code 1
2020-04-01T13:10:09.8776127Z [command]adb shell getprop sys.boot_completed
2020-04-01T13:10:09.8805271Z error: device offline
2020-04-01T13:10:09.8812753Z The process 'adb' failed with exit code 1
2020-04-01T13:10:11.8829167Z [command]adb shell getprop sys.boot_completed
2020-04-01T13:10:11.8858030Z error: device offline
2020-04-01T13:10:11.8865125Z The process 'adb' failed with exit code 1
2020-04-01T13:10:13.8884316Z [command]adb shell getprop sys.boot_completed
2020-04-01T13:10:13.8910017Z error: device offline
2020-04-01T13:10:13.8916757Z The process 'adb' failed with exit code 1
2020-04-01T13:10:15.8949053Z [command]adb shell getprop sys.boot_completed
2020-04-01T13:10:15.8974618Z error: device offline
2020-04-01T13:10:15.8983230Z The process 'adb' failed with exit code 1
2020-04-01T13:10:17.8998877Z [command]adb shell getprop sys.boot_completed
2020-04-01T13:10:17.9026233Z error: device offline
2020-04-01T13:10:17.9033751Z The process 'adb' failed with exit code 1
2020-04-01T13:10:19.9062247Z [command]adb shell getprop sys.boot_completed
2020-04-01T13:10:19.9087631Z error: device offline
2020-04-01T13:10:19.9094115Z The process 'adb' failed with exit code 1
2020-04-01T13:10:21.9118290Z [command]adb shell getprop sys.boot_completed
2020-04-01T13:10:21.9141754Z error: device offline
2020-04-01T13:10:21.9148222Z The process 'adb' failed with exit code 1
2020-04-01T13:10:23.9176772Z [command]adb shell getprop sys.boot_completed
2020-04-01T13:10:23.9201759Z error: device offline
2020-04-01T13:10:23.9208267Z The process 'adb' failed with exit code 1
2020-04-01T13:10:25.9237983Z [command]adb shell getprop sys.boot_completed
2020-04-01T13:10:28.5577583Z 
2020-04-01T13:10:30.5982353Z [command]adb shell getprop sys.boot_completed
2020-04-01T13:10:33.7013035Z 
2020-04-01T13:10:35.7647269Z [command]adb shell getprop sys.boot_completed
2020-04-01T13:10:38.2850873Z 
[The following block is shown again and again]
2020-04-01T13:10:40.3323868Z [command]adb shell getprop sys.boot_completed
2020-04-01T13:10:40.3356703Z error: no devices/emulators found
2020-04-01T13:10:40.3359986Z The process 'adb' failed with exit code 1
[10 minutes later]
2020-04-01T13:20:08.0432667Z The process 'adb' failed with exit code 1
2020-04-01T13:20:08.0435782Z [command]adb -s emulator-5554 emu kill
2020-04-01T13:20:08.0459275Z error: could not connect to TCP port 5554: Connection refused
2020-04-01T13:20:08.0477316Z The process 'adb' failed with exit code 1
2020-04-01T13:20:08.0480439Z ##[error]Timeout waiting for emulator to boot.

ConnectedCheck tests are failing (IOException)

We are using for OpenTracks [1] the android-emulator-runner and so far it was working very nicely!
However, recently we implemented tests doing file system operations and these are failing on Github Actions while working locally.

Details

We have PR (OpenTracksApp/OpenTracks#194 (comment)) that adds test for file system operations that were not checked before.
Sadly this results in
https://github.com/OpenTracksApp/OpenTracks/pull/194/checks?check_run_id=617933592

de.dennisguse.opentracks.content.provider.CustomContentProviderUtilsTest > testDeleteWaypoint_onlyOneWayPointWithPhotoUrl[test(AVD) - 5.0.2] FAILED 
	java.lang.RuntimeException: java.io.IOException: open failed: ENOENT (No such file or directory)
	at de.dennisguse.opentracks.content.data.TestDataUtil.createWaypointWithPhoto(TestDataUtil.java:99)

Are there some limitations within the Android Emulator that prevents us from doing read/writing files?

Github Actions configuration

#https://github.com/marketplace/actions/android-emulator-runner
name: Test
on: [push, pull_request]
jobs:
  test:
    runs-on: macos-latest
    strategy:
      matrix:
        api-level: [21, 29]
        target: [default]
    steps:
      - name: checkout
        uses: actions/checkout@v2

      - name: run tests
        uses: reactivecircus/android-emulator-runner@v2
        with:
          api-level: ${{ matrix.api-level }}
          target: ${{ matrix.target }}
          arch: x86_64
          script: ./gradlew connectedCheck

[1] https://github.com/OpenTracksApp/OpenTracks/

Why running the action on Linux VMs is slow

Hi! Thanks for trying out this action.

I'd like to share a few words on the recently added Linux support to give you a bit of context on why it's much slower than running on macos.

In general if you run this action on a Linux VM (e.g. ubuntu-latest), you'll get very few benefits over other CI solutions (perhaps other than easier configuration and less scripting) as there's no hardware acceleration on ubuntu VMs provided by GitHub Actions.

While you can sort of have some versions of the emulators running without hardware acceleration, in practice you really need hardware acceleration enabled to run the Android Emulator, period. In fact I almost believe that the emulator binary should just not start at all and throw an error if it can't be hardware-accelerated, otherwise it defeats the purpose of having these modern x86, x86_64 system images.

To give you a bit more context, I created this action solely to take advantage of the hardware acceleration support on the macos VM (enabled by HAXM which is installed on macos VMs), and never intended to add Linux support cause I know it won't be a good experience (at least not better than what you already have) without hardware acceleration.

I wrote this article about running Android emulator on CI which should give you more context on running instrumentation tests on CI in general and why the lack of hardware acceleration support from the host machine is still the biggest challenge for running fast and stable instrumented tests on CI.

I understand this might be a bit of a disappointment for some of you, but unfortunately this is a much bigger problem than what can be solved / improved by a GitHub Action.

If you looked at the code, there's no magic at all. It basically automates the following process and makes it a little easier to configure for the common use cases:

  1. Install / update the required Android SDK components including build-tools, platform-tools, platform (for the required API level), emulator and system-images (for the required API level).
  2. Create a new instance of AVD with the provided configurations.
  3. Launch a new Emulator with the provided configurations.
  4. Wait until the Emulator is booted and ready for use.
  5. Run a custom script provided by user once the Emulator is up and running - e.g. ./gradlew connectedCheck.
  6. Kill the Emulator and finish the action.

As soon as you see "Emulator booted." in the log, the job of this action is basically done as from this point on the environment is handed over to your script so anything that works / doesn't work would not have much to do with the action itself, which only makes sure a live Emulator instance is available in the background.


For those of you who are not fortunate enough to be able to use the macOS VM, as an alternative I'd encourage you to have a look at Cirrus CI which provides KVM-enabled Linux VMs and pricing seems pretty reasonable (100% free for opensource projects). I wrote a long article going over all the features relevant to Android and how you can optimize your pipeline etc. I also created some templates to help you get started.

Hope that gives you some context regarding the Linux support, why it's expected to be slow and the alternative you might want to look at.

Thanks!

Support Linux machines

Hello,

As Github charges us 10 times per run on macOS machines, is there any way to support this action for Linux machines, too? Thanks.

Set working directory

I have a problem, because we have such organized github that there is main dir and inside are dirs for python, android, etc. parts of project.

So I need to change current dir before I run script with ./gradlew command.

But I can't find any way to do it.
If I change it in previous step it isn't taken into account in step where I run emulator.

I also tried
script: |
cd AndroidDir
./gradlew ...

This didn't work.

I tried
script: ./AndroidDir/gradlew ... but this gave me:
Project MainDir at : is either no Android app project or build version has not been set to override. Skipping...

Can you include an option to set current dir before running script?

sh: ./gradlew: No such file or directory

Hello,
as in title I got this error while trying to run the UI tests in Flutter.

This is my action

name: Offline tests

on:
  pull_request:
    branches: [ master ]

jobs:
  offline-tests-android:
    runs-on: macOS-latest
    steps:
    - uses: actions/checkout@v1
    - uses: subosito/flutter-action@v1
      with:
        channel: 'beta'
    - name: "Prepare emulator"
      uses: reactivecircus/android-emulator-runner@v2
      with:
        api-level: 29
        script: ./gradlew connectedCheck
    - name: "Run offline tests"
      run: "python3 ci.py offline"    

I tried also this flow, but it hanged forever:

name: Offline tests

on:
  pull_request:
    branches: [ master ]

jobs:
  offline-tests-android:
    runs-on: macOS-latest
    steps:
    - uses: actions/checkout@v1
    - uses: subosito/flutter-action@v1
      with:
        channel: 'beta'
    - name: "Prepare emulator"
      uses: reactivecircus/android-emulator-runner@v2
      with:
        api-level: 29
        script: python3 ci.py offline

The ci script is supposed to do:

flutter test
flutter drive --target=test_driver/tests.dart

Appreciate help

Complete output:

2020-03-17T09:15:08.8986500Z ##[group]Run reactivecircus/android-emulator-runner@v2
2020-03-17T09:15:08.8986640Z with:
2020-03-17T09:15:08.8986720Z   api-level: 29
2020-03-17T09:15:08.8986800Z   script: ./gradlew connectedCheck
2020-03-17T09:15:08.8986870Z   target: default
2020-03-17T09:15:08.8986940Z   arch: x86
2020-03-17T09:15:08.8987030Z   emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim
2020-03-17T09:15:08.8987120Z   disable-animations: true
2020-03-17T09:15:08.8987190Z env:
2020-03-17T09:15:08.8987270Z   FLUTTER_HOME: /Users/runner/hostedtoolcache/flutter/1.14.6-beta/x64
2020-03-17T09:15:08.8987350Z ##[endgroup]
2020-03-17T09:15:08.9964060Z API level: 29
2020-03-17T09:15:09.0006650Z target: default
2020-03-17T09:15:09.0009900Z CPU architecture: x86
2020-03-17T09:15:09.0010370Z Hardware profile: 
2020-03-17T09:15:09.0011780Z emulator options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim
2020-03-17T09:15:09.0012760Z disable animations: true
2020-03-17T09:15:09.0015180Z Script:
2020-03-17T09:15:09.0016100Z ./gradlew connectedCheck
2020-03-17T09:15:09.0018510Z Installing new cmdline-tools.
2020-03-17T09:15:09.0038040Z [command]mkdir /Users/runner/Library/Android/sdk/cmdline-tools
2020-03-17T09:15:09.0171070Z [command]curl -fo commandlinetools.zip https://dl.google.com/android/repository/commandlinetools-linux-6200805_latest.zip
2020-03-17T09:15:09.0338030Z   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
2020-03-17T09:15:09.0432180Z                                  Dload  Upload   Total   Spent    Left  Speed
2020-03-17T09:15:09.0432300Z 
2020-03-17T09:15:09.8087860Z   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
2020-03-17T09:15:10.3100600Z  55 77.8M   55 43.1M    0     0  55.6M      0  0:00:01 --:--:--  0:00:01 55.6M
2020-03-17T09:15:10.3115530Z 100 77.8M  100 77.8M    0     0  60.9M      0  0:00:01  0:00:01 --:--:-- 60.9M
2020-03-17T09:15:10.3271220Z [command]unzip -q commandlinetools.zip -d /Users/runner/Library/Android/sdk/cmdline-tools
2020-03-17T09:15:11.0400870Z [command]rm -f commandlinetools.zip
2020-03-17T09:15:11.0543770Z Installing latest build tools, platform tools, and platform.
2020-03-17T09:15:11.0546560Z [command]sh -c \sdkmanager --install 'build-tools;29.0.3' platform-tools 'platforms;android-29' > /dev/null
2020-03-17T09:15:17.3894350Z Installing latest emulator.
2020-03-17T09:15:17.3902040Z [command]sh -c \sdkmanager --install emulator > /dev/null
2020-03-17T09:15:20.0745350Z Installing system images.
2020-03-17T09:15:20.0847870Z [command]sh -c \sdkmanager --install 'system-images;android-29;default;x86' > /dev/null
2020-03-17T09:15:58.9708390Z Creating AVD without custom profile.
2020-03-17T09:15:58.9711350Z [command]sh -c \echo no | avdmanager create avd --force -n test --abi 'default/x86' --package 'system-images;android-29;default;x86'
2020-03-17T09:16:00.6324010Z Loading local repository...                                                     
2020-03-17T09:16:00.6325810Z [=========                              ] 25% Loading local repository...       
2020-03-17T09:16:00.6327790Z [=========                              ] 25% Fetch remote repository...        
2020-03-17T09:16:00.7009040Z [=======================================] 100% Fetch remote repository...       
2020-03-17T09:16:00.7622720Z Do you wish to create a custom hardware profile? [no] Starting emulator.
2020-03-17T09:16:00.7633390Z [command]sh -c \/Users/runner/Library/Android/sdk/emulator/emulator -avd test -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim &
2020-03-17T09:16:10.9138610Z [command]adb shell getprop sys.boot_completed
2020-03-17T09:16:44.3018000Z * daemon not running; starting now at tcp:5037
2020-03-17T09:16:44.7244410Z * daemon started successfully
2020-03-17T09:16:44.7268730Z error: no devices/emulators found
2020-03-17T09:16:44.7270250Z The process 'adb' failed with exit code 1
2020-03-17T09:16:46.8236450Z [command]adb shell getprop sys.boot_completed
2020-03-17T09:16:46.8307510Z error: no devices/emulators found
2020-03-17T09:16:46.8328590Z The process 'adb' failed with exit code 1
2020-03-17T09:16:46.9970830Z emulator: WARNING: Running on a sytem with less than 8 logical cores. Setting number of virtual cores to 1
2020-03-17T09:16:47.1215870Z emulator: ### WARNING: /etc/localtime does not point to zoneinfo-compatible timezone name
2020-03-17T09:16:47.1216040Z 
2020-03-17T09:16:47.1217100Z emulator: WARNING: EmulatorService.cpp:448: Cannot find certfile: /Users/runner/.android/emulator-grpc.cer security will be disabled.
2020-03-17T09:16:47.1220940Z Started GRPC server at 127.0.0.1:8554
2020-03-17T09:16:47.1442670Z emulator: Cold boot: requested by the user
2020-03-17T09:16:47.1909220Z Your emulator is out of date, please update by launching Android Studio:
2020-03-17T09:16:47.1910610Z  - Start Android Studio
2020-03-17T09:16:47.1911210Z  - Select menu "Tools > Android > SDK Manager"
2020-03-17T09:16:47.1911640Z  - Click "SDK Tools" tab
2020-03-17T09:16:47.1912130Z  - Check "Android Emulator" checkbox
2020-03-17T09:16:47.1912570Z  - Click "OK"
2020-03-17T09:16:47.1912640Z 
2020-03-17T09:16:48.9261710Z [command]adb shell getprop sys.boot_completed
2020-03-17T09:16:48.9348750Z error: device offline
2020-03-17T09:16:48.9349890Z The process 'adb' failed with exit code 1
2020-03-17T09:16:50.9452170Z [command]adb shell getprop sys.boot_completed
2020-03-17T09:16:50.9544070Z error: device offline
2020-03-17T09:16:50.9556440Z The process 'adb' failed with exit code 1
2020-03-17T09:16:52.9561250Z [command]adb shell getprop sys.boot_completed
2020-03-17T09:16:52.9648460Z error: device offline
2020-03-17T09:16:52.9658260Z The process 'adb' failed with exit code 1
2020-03-17T09:16:55.0597650Z [command]adb shell getprop sys.boot_completed
2020-03-17T09:16:55.0707140Z error: device offline
2020-03-17T09:16:55.0719320Z The process 'adb' failed with exit code 1
2020-03-17T09:16:57.1106880Z [command]adb shell getprop sys.boot_completed
2020-03-17T09:16:57.1239030Z error: device offline
2020-03-17T09:16:57.1251400Z The process 'adb' failed with exit code 1
2020-03-17T09:16:59.1258800Z [command]adb shell getprop sys.boot_completed
2020-03-17T09:16:59.1324420Z error: device offline
2020-03-17T09:16:59.1334920Z The process 'adb' failed with exit code 1
2020-03-17T09:17:01.1527910Z [command]adb shell getprop sys.boot_completed
2020-03-17T09:17:01.1601110Z error: device offline
2020-03-17T09:17:01.1607630Z The process 'adb' failed with exit code 1
2020-03-17T09:17:03.1618360Z [command]adb shell getprop sys.boot_completed
2020-03-17T09:17:03.1715520Z error: device offline
2020-03-17T09:17:03.1724170Z The process 'adb' failed with exit code 1
2020-03-17T09:17:04.9452220Z emulator: ### WARNING: /etc/localtime does not point to zoneinfo-compatible timezone name
2020-03-17T09:17:04.9453030Z 
2020-03-17T09:17:05.2092970Z [command]adb shell getprop sys.boot_completed
2020-03-17T09:17:05.2673660Z 
2020-03-17T09:17:07.4128020Z [command]adb shell getprop sys.boot_completed
2020-03-17T09:17:07.4461830Z 
2020-03-17T09:17:09.4496270Z [command]adb shell getprop sys.boot_completed
2020-03-17T09:17:09.4810570Z 
2020-03-17T09:17:11.4835900Z [command]adb shell getprop sys.boot_completed
2020-03-17T09:17:11.5116660Z 
2020-03-17T09:17:13.5290810Z [command]adb shell getprop sys.boot_completed
2020-03-17T09:17:13.5564860Z 
2020-03-17T09:17:15.6524970Z [command]adb shell getprop sys.boot_completed
2020-03-17T09:17:15.7131550Z 
2020-03-17T09:17:17.7151490Z [command]adb shell getprop sys.boot_completed
2020-03-17T09:17:17.7414530Z 
2020-03-17T09:17:19.8923530Z [command]adb shell getprop sys.boot_completed
2020-03-17T09:17:19.9340980Z 
2020-03-17T09:17:21.9947690Z [command]adb shell getprop sys.boot_completed
2020-03-17T09:17:22.0131300Z 
2020-03-17T09:17:24.0152470Z [command]adb shell getprop sys.boot_completed
2020-03-17T09:17:24.0617210Z 
2020-03-17T09:17:26.1877640Z [command]adb shell getprop sys.boot_completed
2020-03-17T09:17:26.2708170Z 
2020-03-17T09:17:28.3525330Z [command]adb shell getprop sys.boot_completed
2020-03-17T09:17:28.3900060Z 
2020-03-17T09:17:30.5334480Z [command]adb shell getprop sys.boot_completed
2020-03-17T09:17:30.6364360Z 
2020-03-17T09:17:32.6433160Z [command]adb shell getprop sys.boot_completed
2020-03-17T09:17:32.7537320Z 
2020-03-17T09:17:34.7597030Z [command]adb shell getprop sys.boot_completed
2020-03-17T09:17:34.8274960Z 
2020-03-17T09:17:36.9384170Z [command]adb shell getprop sys.boot_completed
2020-03-17T09:17:37.1155340Z 1
2020-03-17T09:17:37.1319590Z Emulator booted.
2020-03-17T09:17:37.1334690Z [command]adb shell input keyevent 82
2020-03-17T09:17:38.5951610Z Disabling animations.
2020-03-17T09:17:38.5952470Z [command]adb shell settings put global window_animation_scale 0.0
2020-03-17T09:17:38.6864330Z [command]adb shell settings put global transition_animation_scale 0.0
2020-03-17T09:17:38.8357820Z [command]adb shell settings put global animator_duration_scale 0.0
2020-03-17T09:17:38.9332550Z [command]sh -c \./gradlew connectedCheck
2020-03-17T09:17:38.9449210Z sh: ./gradlew: No such file or directory
2020-03-17T09:17:38.9472230Z ##[error]The process 'sh' failed with exit code 127
2020-03-17T09:17:38.9477670Z [command]adb -s emulator-5554 emu kill
2020-03-17T09:17:38.9550280Z OK: killing emulator, bye bye
2020-03-17T09:17:38.9550840Z OK
2020-03-17T09:17:38.9552040Z emulator: Discarding the changed state: command-line flag
2020-03-17T09:17:38.9552770Z emulator: WARNING: Discarding the changed state (command-line flag).
2020-03-17T09:17:40.6231840Z Cleaning up orphan processes
2020-03-17T09:17:40.6645460Z Terminate orphan process: pid (2364) (adb)

Support multiple actions sequentially in a single job

In some cases users might do the following:

- name: test on API 21
  uses: reactivecircus/android-emulator-runner@v2
  with:
    api-level: 21
    script: ./gradlew connectedCheck
- name: test on API 24
  uses: reactivecircus/android-emulator-runner@v2
  with:
    api-level: 24
    script: ./gradlew connectedCheck
- name: test on API 26
  uses: reactivecircus/android-emulator-runner@v2
  with:
    api-level: 26
    script: ./gradlew connectedCheck
- name: test on API 30
  uses: reactivecircus/android-emulator-runner@v2
  with:
    api-level: 30
    script: ./gradlew connectedCheck

This current fails starting from the second job due to some of the operations not being idempotent.

Default for "script"

Currently, it is required to explicitly set script. In most cases, that would be ./gradlew connectedCheck.

It would be nice if the field could be made optional and default to ./gradlew connectedCheck.

Stuck at Installing System Images

Whenever I try using this action it gets stuck on the Installing system images. step.

Installing system images.
sh -c \sdkmanager --install 'system-images;android-28;default;x86' > /dev/null

It stays like that for 15+ minutes without any error messages. I'm not using any non-default parameters and the api-level is set to 28. I'm running the action on ubuntu-latest.

Does anyone know why that might happen?

Starting up the emulator takes too long (even on macOs VMs)

I've implemented an action for my repo using your emulator android to run a Flutter drive test.
When executing the step were the emulator needs to start and run the tests, it takes too long, over 15minutes.

Is there a way to make them run faster?

Here the action I'm using:

name: flutter drive

on:
  push:
    branches: 
      - develop

jobs:
  drive_android:
    runs-on: macos-latest
    timeout-minutes: 30
    steps:
      - name: checkout
        uses: actions/checkout@v2
      - name: setup-flutter
        uses: subosito/flutter-action@v1
        with:
          channel: "stable"
      - name: Flutter pub get
        run: |
          flutter precache
          flutter doctor -v
          flutter pub get
      - name: Run Flutter Driver tests
        uses: reactivecircus/[email protected]
        with:
          api-level: 29
          target: default
          arch: x86_64
          profile: Nexus 6
          script: flutter drive --target=test_driver/app.dart

Thanks you so much!

Is there a way to set the avd name?

I get this error when running the tests on the emulator

Can not boot Android Emulator with the name: 'Nexus_5X_API_29_x86',
make sure you choose one of the available emulators: test

Is there a way to name the emulator so that I matches our development configuration?

Using an emulator snapshot?

I'd like to use an emulator snapshot I created on my local machine, but I'm having a bit of trouble sorting out how I can use it from the runner. Locally the snapshot resides in ~/.android/avd/Nexus_6_API_29.avd/snapshots. So I copied that into the repo via git-lfs. Then in my job I copy the snapshot from the repo into same path - ~/.android/avd/Nexus_6_API_29.avd/snapshots. However when I set the emulator-options to emulator-options: -snapshot SNAPSHOT_NAME -gpu swiftshader_indirect, it doesn't appear to pick it up and there's no errors or anything about the snapshot not existing.

One obvious issue might be the fact that the avd name in the runner is test not Nexus_6_API_29, but I'm really not sure. So clarification about how this could be done would be welcome.

Migrate to new SDK command-line tools

The new SDK command-line tools have new sdkmanager and avdmanager with Java 8+ support so we don't need to temporarily switch to java8 for installing SDK components and creating AVDs and changing to back to the original version in the environment for running script.

"Google Play Services not supported" error even when targetting google_apis

I'm seeing an error when running my tests of:

[App name] won't run without Google Play services, which are not supported by your device.

Even when targetting google_apis. Here's the YAML snippet:

jobs:
  test:
    runs-on: macOS-latest
      strategy:
        matrix:
          api-level: [29]
          target: [google_apis]
          arch: [x86]

I've added screenshots in too and can see that the Activities are getting displayed OK, but with the Google Play Service modal dialog in front which is causing the tests to fail.

I can't see any warnings or errors in my build log with --info or --stacktrace enabled, and tests are just failing with a NoMatchingViewException because of the dialog.

Any ideas what may be causing this? I'm using Android 10 / API level 29 on a local emulator and tests pass with no issues.

Let me know if you need more details.

Running shell script

can I run shell script once emulator boots up?
Workflow looks like

    - name: Instrumentation tests
      uses: reactivecircus/android-emulator-runner@v2
    with:
        api-level: 29
        arch: x86
  - name: script tests
    run: ./test.sh`

i am doing some custom logic inside test.sh
with this, its give Input required and not supplied: script

Running Flutter driver tests occasionally hangs

Hello,
I have about 75%/25% success rate (fails 25% times) when running flutter driver tests.

this is my workflow:

name: Offline tests

on:
  pull_request:
    branches: [ master ]

jobs:
  Android:
    strategy:
      matrix:
        device:
          - "pixel_xl"
      fail-fast: false
    runs-on: macOS-latest
    steps:
    - uses: actions/checkout@v1
    - uses: subosito/flutter-action@v1
      with:
        channel: 'beta'
    - name: "Run offline tests"
      uses: reactivecircus/android-emulator-runner@v2
      with:
        profile: ${{ matrix.device }}
        api-level: 29
        script: python3 ci.py offline

python script does the following:
flutter drive --target=test_driver/tests/offline/offline.dart

Output of failure:

2020-03-18T03:16:30.5113730Z ##[group]Run reactivecircus/android-emulator-runner@v2
2020-03-18T03:16:30.5113900Z with:
2020-03-18T03:16:30.5114000Z   profile: pixel_xl
2020-03-18T03:16:30.5114120Z   api-level: 29
2020-03-18T03:16:30.5114210Z   script: python3 ci.py offline
2020-03-18T03:16:30.5114310Z   target: default
2020-03-18T03:16:30.5114390Z   arch: x86
2020-03-18T03:16:30.5114490Z   emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim
2020-03-18T03:16:30.5114600Z   disable-animations: true
2020-03-18T03:16:30.5114700Z env:
2020-03-18T03:16:30.5114800Z   FLUTTER_HOME: /Users/runner/hostedtoolcache/flutter/1.15.17-beta/x64
2020-03-18T03:16:30.5114910Z ##[endgroup]
2020-03-18T03:16:30.5755970Z API level: 29
2020-03-18T03:16:30.5761270Z target: default
2020-03-18T03:16:30.5762430Z CPU architecture: x86
2020-03-18T03:16:30.5762650Z Hardware profile: pixel_xl
2020-03-18T03:16:30.5764000Z emulator options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim
2020-03-18T03:16:30.5764460Z disable animations: true
2020-03-18T03:16:30.5766970Z Script:
2020-03-18T03:16:30.5768220Z python3 ci.py offline
2020-03-18T03:16:30.5783890Z Installing new cmdline-tools.
2020-03-18T03:16:30.5796260Z [command]mkdir /Users/runner/Library/Android/sdk/cmdline-tools
2020-03-18T03:16:30.5878910Z [command]curl -fo commandlinetools.zip https://dl.google.com/android/repository/commandlinetools-linux-6200805_latest.zip
2020-03-18T03:16:30.6329350Z   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
2020-03-18T03:16:30.6330310Z                                  Dload  Upload   Total   Spent    Left  Speed
2020-03-18T03:16:30.6330730Z 
2020-03-18T03:16:31.3549110Z   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
2020-03-18T03:16:31.5983560Z  68 77.8M   68 53.4M    0     0  74.0M      0  0:00:01 --:--:--  0:00:01 73.9M
2020-03-18T03:16:31.5984500Z 100 77.8M  100 77.8M    0     0  80.7M      0 --:--:-- --:--:-- --:--:-- 80.6M
2020-03-18T03:16:31.6142370Z [command]unzip -q commandlinetools.zip -d /Users/runner/Library/Android/sdk/cmdline-tools
2020-03-18T03:16:32.1597950Z [command]rm -f commandlinetools.zip
2020-03-18T03:16:32.1700490Z Installing latest build tools, platform tools, and platform.
2020-03-18T03:16:32.1701200Z [command]sh -c \sdkmanager --install 'build-tools;29.0.3' platform-tools 'platforms;android-29' > /dev/null
2020-03-18T03:16:36.0194650Z Installing latest emulator.
2020-03-18T03:16:36.0196890Z [command]sh -c \sdkmanager --install emulator > /dev/null
2020-03-18T03:16:38.4418890Z Installing system images.
2020-03-18T03:16:38.4420190Z [command]sh -c \sdkmanager --install 'system-images;android-29;default;x86' > /dev/null
2020-03-18T03:17:25.1130520Z Creating AVD with custom profile pixel_xl
2020-03-18T03:17:25.1132870Z [command]avdmanager create avd --force -n test --abi default/x86 --package system-images;android-29;default;x86 --device pixel_xl
2020-03-18T03:17:26.4970310Z Loading local repository...                                                     
2020-03-18T03:17:26.4971800Z [=========                              ] 25% Loading local repository...       
2020-03-18T03:17:26.4972030Z [=========                              ] 25% Fetch remote repository...        
2020-03-18T03:17:27.0044290Z [=======================================] 100% Fetch remote repository...       
2020-03-18T03:17:27.0044590Z Starting emulator.
2020-03-18T03:17:27.0047440Z [command]sh -c \/Users/runner/Library/Android/sdk/emulator/emulator -avd test -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim &
2020-03-18T03:17:37.0751220Z [command]adb shell getprop sys.boot_completed
2020-03-18T03:18:01.6460770Z * daemon not running; starting now at tcp:5037
2020-03-18T03:18:01.6461060Z * daemon started successfully
2020-03-18T03:18:01.6461200Z error: no devices/emulators found
2020-03-18T03:18:01.6462000Z The process 'adb' failed with exit code 1
2020-03-18T03:18:03.4012420Z [command]adb shell getprop sys.boot_completed
2020-03-18T03:18:03.4086820Z error: no devices/emulators found
2020-03-18T03:18:03.4093260Z The process 'adb' failed with exit code 1
2020-03-18T03:18:03.8130790Z emulator: WARNING: Running on a sytem with less than 8 logical cores. Setting number of virtual cores to 1
2020-03-18T03:18:03.9199330Z emulator: ### WARNING: /etc/localtime does not point to zoneinfo-compatible timezone name
2020-03-18T03:18:03.9200200Z 
2020-03-18T03:18:03.9201360Z emulator: WARNING: EmulatorService.cpp:448: Cannot find certfile: /Users/runner/.android/emulator-grpc.cer security will be disabled.
2020-03-18T03:18:03.9204090Z Started GRPC server at 127.0.0.1:8554
2020-03-18T03:18:03.9410890Z emulator: Cold boot: requested by the user
2020-03-18T03:18:03.9829010Z Your emulator is out of date, please update by launching Android Studio:
2020-03-18T03:18:03.9830250Z  - Start Android Studio
2020-03-18T03:18:03.9830810Z  - Select menu "Tools > Android > SDK Manager"
2020-03-18T03:18:03.9831270Z  - Click "SDK Tools" tab
2020-03-18T03:18:03.9831720Z  - Check "Android Emulator" checkbox
2020-03-18T03:18:03.9832210Z  - Click "OK"
2020-03-18T03:18:03.9832280Z 
2020-03-18T03:18:05.4093320Z [command]adb shell getprop sys.boot_completed
2020-03-18T03:18:05.4155300Z error: device offline
2020-03-18T03:18:05.4165280Z The process 'adb' failed with exit code 1
2020-03-18T03:18:07.4307070Z [command]adb shell getprop sys.boot_completed
2020-03-18T03:18:07.4366650Z error: device offline
2020-03-18T03:18:07.4376580Z The process 'adb' failed with exit code 1
2020-03-18T03:18:09.4494030Z [command]adb shell getprop sys.boot_completed
2020-03-18T03:18:09.4558460Z error: device offline
2020-03-18T03:18:09.4566530Z The process 'adb' failed with exit code 1
2020-03-18T03:18:11.6056570Z [command]adb shell getprop sys.boot_completed
2020-03-18T03:18:11.6143450Z error: device offline
2020-03-18T03:18:11.6150300Z The process 'adb' failed with exit code 1
2020-03-18T03:18:13.7505430Z [command]adb shell getprop sys.boot_completed
2020-03-18T03:18:13.7567600Z error: device offline
2020-03-18T03:18:13.7576180Z The process 'adb' failed with exit code 1
2020-03-18T03:18:15.8665390Z [command]adb shell getprop sys.boot_completed
2020-03-18T03:18:15.8740920Z error: device offline
2020-03-18T03:18:15.8748760Z The process 'adb' failed with exit code 1
2020-03-18T03:18:17.8820030Z [command]adb shell getprop sys.boot_completed
2020-03-18T03:18:17.8957680Z error: device offline
2020-03-18T03:18:17.8981210Z The process 'adb' failed with exit code 1
2020-03-18T03:18:19.9125590Z [command]adb shell getprop sys.boot_completed
2020-03-18T03:18:19.9995860Z emulator: ### WARNING: /etc/localtime does not point to zoneinfo-compatible timezone name
2020-03-18T03:18:19.9996200Z 
2020-03-18T03:18:20.0465200Z 
2020-03-18T03:18:22.1619340Z [command]adb shell getprop sys.boot_completed
2020-03-18T03:18:22.1911630Z 
2020-03-18T03:18:24.1944420Z [command]adb shell getprop sys.boot_completed
2020-03-18T03:18:24.2224950Z 
2020-03-18T03:18:26.2313830Z [command]adb shell getprop sys.boot_completed
2020-03-18T03:18:26.2701800Z 
2020-03-18T03:18:28.2741570Z [command]adb shell getprop sys.boot_completed
2020-03-18T03:18:28.3223840Z 
2020-03-18T03:18:30.3723600Z [command]adb shell getprop sys.boot_completed
2020-03-18T03:18:30.4556800Z 
2020-03-18T03:18:32.4799700Z [command]adb shell getprop sys.boot_completed
2020-03-18T03:18:33.1867850Z 
2020-03-18T03:18:34.6001790Z [command]adb shell getprop sys.boot_completed
2020-03-18T03:18:34.6868700Z 
2020-03-18T03:18:36.8078490Z [command]adb shell getprop sys.boot_completed
2020-03-18T03:18:36.8469570Z 
2020-03-18T03:18:38.9057460Z [command]adb shell getprop sys.boot_completed
2020-03-18T03:18:38.9537480Z 
2020-03-18T03:18:41.0070170Z [command]adb shell getprop sys.boot_completed
2020-03-18T03:18:41.0558030Z 
2020-03-18T03:18:43.1412010Z [command]adb shell getprop sys.boot_completed
2020-03-18T03:18:43.1995510Z 
2020-03-18T03:18:45.2261440Z [command]adb shell getprop sys.boot_completed
2020-03-18T03:18:45.2965730Z 1
2020-03-18T03:18:45.2987730Z Emulator booted.
2020-03-18T03:18:45.2990650Z [command]adb shell input keyevent 82
2020-03-18T03:18:46.8699440Z Disabling animations.
2020-03-18T03:18:46.8701120Z [command]adb shell settings put global window_animation_scale 0.0
2020-03-18T03:18:47.1028510Z [command]adb shell settings put global transition_animation_scale 0.0
2020-03-18T03:18:47.2083110Z [command]adb shell settings put global animator_duration_scale 0.0
2020-03-18T03:18:47.3472770Z [command]sh -c \python3 ci.py offline
2020-03-18T03:18:47.9543900Z emulator: INFO: boot completed
2020-03-18T03:18:47.9559610Z emulator: INFO: boot time 46281 ms
2020-03-18T03:18:47.9560230Z emulator: Increasing screen off timeout, logcat buffer size to 2M.
2020-03-18T03:18:47.9560790Z emulator: Revoking microphone permissions for Google App.
2020-03-18T03:18:54.0511240Z 
2020-03-18T03:18:54.0613520Z   ╔════════════════════════════════════════════════════════════════════════════╗
2020-03-18T03:18:54.0718130Z   ║                 Welcome to Flutter! - https://flutter.dev                  ║
2020-03-18T03:18:54.0818460Z   ║                                                                            ║
2020-03-18T03:18:54.0920330Z   ║ The Flutter tool uses Google Analytics to anonymously report feature usage ║
2020-03-18T03:18:54.1026420Z   ║ statistics and basic crash reports. This data is used to help improve      ║
2020-03-18T03:18:54.1129490Z   ║ Flutter tools over time.                                                   ║
2020-03-18T03:18:54.1130480Z   ║                                                                            ║
2020-03-18T03:18:54.1233440Z   ║ Flutter tool analytics are not sent on the very first run. To disable      ║
2020-03-18T03:18:54.1332380Z   ║ reporting, type 'flutter config --no-analytics'. To display the current    ║
2020-03-18T03:18:54.1434240Z   ║ setting, type 'flutter config'. If you opt out of analytics, an opt-out    ║
2020-03-18T03:18:54.1535820Z   ║ event will be sent, and then no further information will be sent by the    ║
2020-03-18T03:18:54.1636760Z   ║ Flutter tool.                                                              ║
2020-03-18T03:18:54.1738170Z   ║                                                                            ║
2020-03-18T03:18:54.1838640Z   ║ By downloading the Flutter SDK, you agree to the Google Terms of Service.  ║
2020-03-18T03:18:54.1940120Z   ║ Note: The Google Privacy Policy describes how data is handled in this      ║
2020-03-18T03:18:54.1956120Z   ║ service.                                                                   ║
2020-03-18T03:18:54.1990770Z   ║                                                                            ║
2020-03-18T03:18:54.2011720Z   ║ Moreover, Flutter includes the Dart SDK, which may send usage metrics and  ║
2020-03-18T03:18:54.2012410Z   ║ crash reports to Google.                                                   ║
2020-03-18T03:18:54.2012960Z   ║                                                                            ║
2020-03-18T03:18:54.2013500Z   ║ Read about data we send with crash reports:                                ║
2020-03-18T03:18:54.2014150Z   ║ https://flutter.dev/docs/reference/crash-reporting                         ║
2020-03-18T03:18:54.2014760Z   ║                                                                            ║
2020-03-18T03:18:54.2015320Z   ║ See Google's privacy policy:                                               ║
2020-03-18T03:18:54.2057450Z   ║ https://policies.google.com/privacy                                        ║
2020-03-18T03:18:54.2058760Z   ╚════════════════════════════════════════════════════════════════════════════╝
2020-03-18T03:18:54.2058940Z 
2020-03-18T03:19:10.8101360Z Running "flutter pub get" in host_app...                            4.3s
2020-03-18T03:19:11.7354870Z emulator: ### WARNING: /etc/localtime does not point to zoneinfo-compatible timezone name
2020-03-18T03:19:11.7355210Z 
2020-03-18T03:19:12.4907610Z Using device Android SDK built for x86.
2020-03-18T03:19:12.4908440Z Starting application: test_driver/tests/offline/offline.dart
2020-03-18T03:19:12.5941390Z "build/host/outputs/apk/app.apk" does not exist.
2020-03-18T03:20:33.5931920Z Running Gradle task 'assembleDebug'...                          
2020-03-18T03:20:33.6032870Z /Users/runner/hostedtoolcache/flutter/1.15.17-beta/x64/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.5.6+1/android/src/main/java/io/flutter/plugins/sharedpreferences/SharedPreferencesPlugin.java:25: warning: [deprecation] getFlutterEngine() in FlutterPluginBinding has been deprecated
2020-03-18T03:20:33.6163820Z 
2020-03-18T03:20:33.6334810Z     setupChannel(binding.getFlutterEngine().getDartExecutor(), binding.getApplicationContext());
2020-03-18T03:20:33.6435610Z 
2020-03-18T03:20:33.6612260Z                         ^
2020-03-18T03:20:33.8834470Z 
2020-03-18T03:20:33.8935860Z 1 warning
2020-03-18T03:21:14.8569330Z Running Gradle task 'assembleDebug'...                            122.2s (!)
2020-03-18T03:21:15.5934270Z ✓ Built build/host/outputs/apk/debug/app-debug.apk.
2020-03-18T03:21:17.3351230Z Installing build/host/outputs/apk/app.apk...                        1.4s
2020-03-18T03:21:21.5265800Z I/flutter ( 3417): Observatory listening on http://127.0.0.1:46019/eGdBMvuFN_g=/
2020-03-18T03:21:26.0192020Z 00:00 �[32m+0�[0m: (setUpAll)�[0m
2020-03-18T03:21:26.0192500Z 
2020-03-18T03:21:26.0895390Z VMServiceFlutterDriver: Connecting to Flutter application at http://127.0.0.1:49693/eGdBMvuFN_g=/
2020-03-18T03:21:32.5534630Z VMServiceFlutterDriver: It is taking an unusually long time to connect to the VM...
--- THIS OUTPUT LINE REPEATS FOREVER FOR FEW MINUTES ---
2020-03-18T03:30:01.0958370Z VMServiceFlutterDriver: It is taking an unusually long time to connect to the VM...
2020-03-18T03:30:01.7822960Z ##[error]The operation was canceled.

appreciate help

The pipeline fails with "Emulator is out of date" error

Hi! I have the following android.yml:

name: Android CI
on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  build:
    runs-on: macos-latest

    steps:
    - uses: actions/checkout@v2
    - name: set up JDK 1.8
      uses: actions/setup-java@v1
      with:
        java-version: 1.8
    - name: Build with Gradle
      run: ./gradlew build
      
  test:
    runs-on: macos-latest
    strategy:
      matrix:
        api-level: [19, 25, 29]
        target: [default]
    steps:
    - name: checkout
      uses: actions/checkout@v2

    - name: run tests
      uses: reactivecircus/android-emulator-runner@v2
      with:
        api-level: ${{ matrix.api-level }}
        target: ${{ matrix.target }}
        arch: x86
        profile: Nexus 6
        script: ./gradlew connectedCheck

It is almost a copy past of the config provided in Usage section of your readme.md. When I trying to run this config it fails every time with the following error:

emulator: Cold boot: requested by the user
Your emulator is out of date, please update by launching Android Studio:
 - Start Android Studio
 - Select menu "Tools > Android > SDK Manager"
 - Click "SDK Tools" tab
 - Check "Android Emulator" checkbox
 - Click "OK"

Any suggestions?

No WebView installed

I'm trying to test android application that uses WebViews.

But test crashes with following error:
android.util.AndroidRuntimeException: android.webkit.WebViewFactory$MissingWebViewPackageException: Failed to load WebView provider: No WebView installed at android.webkit.WebViewFactory.getProviderClass(WebViewFactory.java:438) Tests on test(AVD) - 8.0.0 failed: Instrumentation run failed due to 'Process crashed.'

I tried to wait 15 minutes to let Android install WebViews by itself. But it didn't help.

Can anything be done about that?

emulator not starting

It keeps on repeating this

adb: no devices/emulators found
The process 'adb' failed with exit code 1

Getting error while starting emulator

Hi
Getting following error
Run reactivecircus/android-emulator-runner@v2 You're running a Linux VM where hardware acceleration is not available. Please consider using a macOS VM instead to take advantage of native hardware acceleration support provided by HAXM. API level: 27 target: default CPU architecture: x86 Hardware profile: emulator options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim disable animations: true Script: fastlane app Installing new cmdline-tools. sudo mkdir undefined/cmdline-tools mkdir: cannot create directory ‘undefined/cmdline-tools’: No such file or directory

yml looks like

name: Testing CI

on:
push:
branches:
- test
jobs:
build:
name: Unit Test
runs-on: self-hosted

steps:
  - name: checkout
    uses: actions/checkout@v2
  - name: Instrumentation tests
    uses: reactivecircus/android-emulator-runner@v2

    with:
      api-level: 27
      arch: x86
      script: fastlane app

Timeout waiting for emulator to boot when using build matrix

I have successfully added instrumented test in my CI. But then I tried to add build matrix and it failed:

/Users/runner/Library/Android/sdk/platform-tools/adb -s emulator-5554 emu kill
OK: killing emulator, bye bye
OK
emulator: Discarding the changed state: command-line flag
emulator: WARNING: Discarding the changed state (command-line flag).
##[error]Timeout waiting for emulator to boot.
##[error]Node run failed with exit code 1

Job details: https://github.com/andreynovikov/trekarta/runs/324416797
Workflow configuration change: andreynovikov/trekarta@f69033a

error: device offline

Hi,

i just found your GitHub action and wanted to use it for instrumented tests.

Unfortunately i don't get it working. Every run ends in an endless-loop, like this:

2020-04-18T10:50:38.3709819Z Do you wish to create a custom hardware profile? [no] Starting emulator.
2020-04-18T10:50:38.3710947Z [command]sh -c \/usr/local/lib/android/sdk/emulator/emulator -avd test -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -accel off &
2020-04-18T10:50:38.5434456Z emulator: ERROR: AdbHostServer.cpp:102: Unable to connect to adb daemon on port: 5037
2020-04-18T10:50:38.8611089Z emulator: WARNING: x86 emulation may not work without hardware acceleration!
2020-04-18T10:50:38.8611715Z emulator: Cold boot: requested by the user
2020-04-18T10:50:48.0223424Z Your emulator is out of date, please update by launching Android Studio:
2020-04-18T10:50:48.0224339Z  - Start Android Studio
2020-04-18T10:50:48.0224850Z  - Select menu "Tools > Android > SDK Manager"
2020-04-18T10:50:48.0225247Z  - Click "SDK Tools" tab
2020-04-18T10:50:48.0225575Z  - Check "Android Emulator" checkbox
2020-04-18T10:50:48.0225857Z  - Click "OK"
2020-04-18T10:50:48.0225987Z 
2020-04-18T10:50:48.0226140Z [command]adb shell getprop sys.boot_completed
2020-04-18T10:50:48.0287652Z * daemon not running; starting now at tcp:5037
2020-04-18T10:50:48.1271823Z * daemon started successfully
2020-04-18T10:50:48.1279811Z The process 'adb' failed with exit code 1
2020-04-18T10:50:48.1280228Z error: device offline
2020-04-18T10:50:50.1297670Z [command]adb shell getprop sys.boot_completed
2020-04-18T10:50:50.1334241Z error: device offline
2020-04-18T10:50:50.1343910Z The process 'adb' failed with exit code 1
2020-04-18T10:50:52.1376072Z [command]adb shell getprop sys.boot_completed
2020-04-18T10:50:52.1414803Z error: device offline
2020-04-18T10:50:52.1423024Z The process 'adb' failed with exit code 1
2020-04-18T10:50:54.1452862Z [command]adb shell getprop sys.boot_completed
2020-04-18T10:50:54.1494499Z error: device offline
2020-04-18T10:50:54.1509088Z The process 'adb' failed with exit code 1
2020-04-18T10:50:56.1540131Z [command]adb shell getprop sys.boot_completed
2020-04-18T10:50:56.1581878Z error: device offline
2020-04-18T10:50:56.1591998Z The process 'adb' failed with exit code 1
2020-04-18T10:50:58.1622531Z [command]adb shell getprop sys.boot_completed
2020-04-18T10:50:58.1657872Z error: device offline
2020-04-18T10:50:58.1667429Z The process 'adb' failed with exit code 1
2020-04-18T10:51:00.1692766Z [command]adb shell getprop sys.boot_completed
2020-04-18T10:51:00.1728925Z error: device offline
2020-04-18T10:51:00.1736781Z The process 'adb' failed with exit code 1
2020-04-18T10:51:02.1767240Z [command]adb shell getprop sys.boot_completed

You can find my configuration here: https://github.com/stefan-niedermann/nextcloud-deck/blob/instrumented-tests-ci/.github/workflows/android.yml#L25-L39 and the full log output here: https://github.com/stefan-niedermann/nextcloud-deck/runs/597664917 (raw)

Do you have any clue what i am doing wrong?

Thank you in advance

Linux: test fails, unknown API level

Hi,
I'm using your action for automated screenshot tests. Great job! My job runs fine on Mac OS, I recently found out that you also support Linux, which can save us a lot of money. Screenshots tests might be a good use-case for Linux, I don't really need hardware acceleration (Facebook screenshot library only uses emulator to layout views, nothing is shown on the screen).

Here is my configuration:

jobs:
  build:

    runs-on: ubuntu-18.04

    steps:
    - name: Run screenshot tests
      uses: reactivecircus/android-emulator-runner@v2
      with:
        api-level: 27
        arch: x86_64
        profile: pixel
        script: ./gradlew verifyQaDebugAndroidTestScreenshotTest recordQaDebugAndroidTestScreenshotTest --continue

and the test fails with this:

> Task :app:validateSigningDevDebugAndroidTest UP-TO-DATE
> Task :app:packageDevDebugAndroidTest UP-TO-DATE
[PropertyFetcher]: ShellCommandUnresponsiveException getting properties for device emulator-5554: null
[PropertyFetcher]: ShellCommandUnresponsiveException getting properties for device emulator-5554: null

> Task :app:connectedDevDebugAndroidTest
Skipping device 'test(AVD)' for 'app:DEV': Unknown API Level

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

Any ideas?

Add option to upload device logs as artifacts

I think it would be really cool if this action had the option upload_device_logs to help with a scenario where you have Test instrumentation crashed. check blah blah blah

I believe the piping of the logs to file is as simple as

adb -e logcat *:D > logcat.log

Thanks for this action, really saved a lot of time

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.