ReactiveCircus / android-emulator-runner

A GitHub Action for installing, configuring and running hardware-accelerated Android Emulators on macOS virtual machines.
Apache License 2.0
946 stars 185 forks source link

Emulator doesn't start when caching is set up #278

Open repeato-qa opened 1 year ago

repeato-qa commented 1 year ago

The emulator just never starts. This is the log we get:

Launch Emulator
  /bin/sh -c \printf 'hw.cpu.ncore=2
  ' >> /Users/runner/.android/avd/test.avd/config.ini
  /bin/sh -c \printf 'hw.ramSize=8096M
  ' >> /Users/runner/.android/avd/test.avd/config.ini
  Starting emulator.
  /bin/sh -c \/Users/runner/Library/Android/sdk/emulator/emulator -avd test -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none &
  PANIC: Broken AVD system path. Check your ANDROID_SDK_ROOT value [/Users/runner/Library/Android/sdk]!
  INFO    | Android emulator version 31.3.12.0 (build_id 9126400) (CL:N/A)
  emulator: INFO: path_getAvdSystemPath: AVD test has path /Users/runner/.android/avd/test.avd
  emulator: INFO: path_getAvdSystemPath: trying to check whether /Users/runner/Library/Android/sdk is a valid sdk root
  emulator: WARN: path_getAvdSystemPath: /Users/runner/Library/Android/sdk/system-images/android-29/default/x86/ is not a valid directory.
  emulator: WARN: path_getAvdSystemPath: emulator has searched the above paths but found no valid sdk root directory.
  /Users/runner/Library/Android/sdk/platform-tools/adb shell getprop sys.boot_completed
  * daemon not running; starting now at tcp:5037
  * daemon started successfully
  adb: no devices/emulators found
  The process '/Users/runner/Library/Android/sdk/platform-tools/adb' failed with exit code 1
  /Users/runner/Library/Android/sdk/platform-tools/adb shell getprop sys.boot_completed
  adb: no devices/emulators found
  The process '/Users/runner/Library/Android/sdk/platform-tools/adb' failed with exit code 1
  /Users/runner/Library/Android/sdk/platform-tools/adb shell getprop sys.boot_completed
  adb: no devices/emulators found
  The process '/Users/runner/Library/Android/sdk/platform-tools/adb' failed with exit code 1
  /Users/runner/Library/Android/sdk/platform-tools/adb shell getprop sys.boot_completed
  adb: no devices/emulators found
  The process '/Users/runner/Library/Android/sdk/platform-tools/adb' failed with exit code 1
  /Users/runner/Library/Android/sdk/platform-tools/adb shell getprop sys.boot_completed
  adb: no devices/emulators found
  The process '/Users/runner/Library/Android/sdk/platform-tools/adb' failed with exit code 1
  /Users/runner/Library/Android/sdk/platform-tools/adb shell getprop sys.boot_completed
  adb: no devices/emulators found
  The process '/Users/runner/Library/Android/sdk/platform-tools/adb' failed with exit code 1
...

And this is the workflow file:

name: Run Repeato CLI

on:
  release:
    types: [published]
  push:
    branches:
      - main

jobs:
  repeato-cli:
    name: Build and run repeato tests using REPEATO CLI
    runs-on: macos-latest

    steps:
      - uses: actions/setup-node@v3
        with:
          node-version: '16'

      - uses: actions/checkout@v3

      - name: Checkout flutter app repo
        uses: actions/checkout@v3
        with:
          repository: repeato-qa/flutter-demo-app
          path: demo-app
          clean: false

      - name: Checkout workspace repo
        uses: actions/checkout@v3
        with:
          repository: repeato-qa/demo-workspace
          path: workspace-tests
          clean: false

      - name: Install Flutter
        uses: subosito/flutter-action@v2
        with:
          flutter-version: '3.0.1'
          channel: 'stable'
      - run: cd demo-app && flutter pub get
      - run: cd demo-app && flutter build apk --split-per-abi

      - name: Upload APK
        uses: actions/upload-artifact@v3
        with:
          name: release-apk
          path: demo-app/build/app/outputs/flutter-apk/app-x86_64-release.apk

      - name: Gradle cache
        uses: gradle/gradle-build-action@v2

      - name: AVD cache
        uses: actions/cache@v3
        id: avd-cache
        with:
          path: |
            ~/.android/avd/*
            ~/.android/adb*
          key: avd-29

      - 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: 29
          force-avd-creation: true
          emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
          disable-animations: false
          target: google_apis
          profile: pixel_3a
          ram-size: 8096M
          script: echo "Generated AVD snapshot for caching."

      - name: Start Android emulator and run tests
        uses: ReactiveCircus/android-emulator-runner@v2.26.0
        with:
          api-level: 29
          force-avd-creation: false
          emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
          disable-animations: true
          target: google_apis
          profile: pixel_3a
          ram-size: 8096M
          script: npx @repeato/cli-testrunner --workspaceDir "${GITHUB_WORKSPACE}/workspace-tests" --batchId 0 --licenseKey ${{ secrets.REPEATO_LICENSE_KEY }} --outputDir "${GITHUB_WORKSPACE}/batch-report"
mrk-han commented 1 year ago

@repeato-qa Can you try pinning the action to a specific release commit in both steps?

Also, has the cache ever worked for you or do you think this is a regression?

repeato-qa commented 1 year ago

Hi @mrk-han , it's the first time we are trying the cache. We now tried once more using a specific commit, and it's failing again. You can check the log here: https://github.com/repeato-qa/Repeato-CLI-prebuilt/actions/runs/3280238936/jobs/5400777210#step:9:988

mrk-han commented 1 year ago

@repeato-qa Here's your problem 2022-10-19T09:10:35.5278660Z PANIC: Broken AVD system path. Check your ANDROID_SDK_ROOT value [/Users/runner/Library/Android/sdk]! for that last run

mrk-han commented 1 year ago

@repeato-qa Same with the above run:

 PANIC: Broken AVD system path. Check your ANDROID_SDK_ROOT value [/Users/runner/Library/Android/sdk]!
  INFO    | Android emulator version 31.3.12.0 (build_id 9126400) (CL:N/A)
  emulator: INFO: path_getAvdSystemPath: AVD test has path /Users/runner/.android/avd/test.avd
  emulator: INFO: path_getAvdSystemPath: trying to check whether /Users/runner/Library/Android/sdk is a valid sdk root
  emulator: WARN: path_getAvdSystemPath: /Users/runner/Library/Android/sdk/system-images/android-29/default/x86/ is not a valid directory.

I think we need to check if there is variance on the macOS-12 agent with how the android tooling is set up, and also I'll check how we are calling to the SDK from this repo.

Can you do me a favor and tell me which version of Java you are using?

stoefln commented 1 year ago

@mrk-han I am not sure what you mean by version of Java. Isn't that all part of the github workflow?

mrk-han commented 1 year ago

@stoefln I don't think it's super relevant to your problem, but I think Flutter projects are on Java 11 now? Usually on native we have to set it if the default version is different than what comes with the runner.

Sorry, I'm not sure of the root cause of why your ANDROID_SDK_ROOT value isn't set right -- it might be worth filing an issue on the Github Runner page perhaps? Because your setup seems pretty standard.

baconcheese113 commented 1 year ago

I believe I'm running into the same problem, except it boots up and then gets a device unauthorized error https://github.com/baconcheese113/handle-it-app/actions/runs/3636560917/jobs/6137293030

  /Users/runner/Library/Android/sdk/platform-tools/adb shell getprop sys.boot_completed
  The process '/Users/runner/Library/Android/sdk/platform-tools/adb' failed with exit code 1
  adb: device offline
  The process '/Users/runner/Library/Android/sdk/platform-tools/adb' failed with exit code 1
  /Users/runner/Library/Android/sdk/platform-tools/adb shell getprop sys.boot_completed
  adb: device offline
  /Users/runner/Library/Android/sdk/platform-tools/adb shell getprop sys.boot_completed
  The process '/Users/runner/Library/Android/sdk/platform-tools/adb' failed with exit code 1
  adb: device offline
  /Users/runner/Library/Android/sdk/platform-tools/adb shell getprop sys.boot_completed
  The process '/Users/runner/Library/Android/sdk/platform-tools/adb' failed with exit code 1
  adb: device offline
  INFO    | boot completed
  INFO    | boot time 51155 ms
  INFO    | Increasing screen off timeout, logcat buffer size to 2M.
  INFO    | Revoking microphone permissions for Google App.
  /Users/runner/Library/Android/sdk/platform-tools/adb shell getprop sys.boot_completed
  The process '/Users/runner/Library/Android/sdk/platform-tools/adb' failed with exit code 1
  adb: device unauthorized.
  This adb server's $ADB_VENDOR_KEYS is not set
  Try 'adb kill-server' if that seems wrong.
  Otherwise check for a confirmation dialog on your device.
  /Users/runner/Library/Android/sdk/platform-tools/adb shell getprop sys.boot_completed
  The process '/Users/runner/Library/Android/sdk/platform-tools/adb' failed with exit code 1
  adb: device unauthorized.
  This adb server's $ADB_VENDOR_KEYS is not set
  Try 'adb kill-server' if that seems wrong.
  Otherwise check for a confirmation dialog on your device.
  /Users/runner/Library/Android/sdk/platform-tools/adb shell getprop sys.boot_completed
  The process '/Users/runner/Library/Android/sdk/platform-tools/adb' failed with exit code 1
  adb: device unauthorized.
  This adb server's $ADB_VENDOR_KEYS is not set
  Try 'adb kill-server' if that seems wrong.
  Otherwise check for a confirmation dialog on your device.
  WARNING | /etc/localtime does not point to zoneinfo-compatible timezone name
tenzap commented 1 year ago

In your yml file there is : target: google_apis The log reports:

emulator: WARN: path_getAvdSystemPath: /Users/runner/Library/Android/sdk/system-images/android-29/default/x86/ is not a valid directory.

So maybe in your cache you have the image for "default" while you want to use google_api. Maybe that is the problem.

Does deleting your cache file fix the issue?

BTW, I think the cache should use in its "key" the APIbut also the targetand the arch. Apparently the cache doesn't make the distinction. I'm facing the same problem with a matrix setup in the job.

arburk commented 7 months ago

FYI: The caching issue still persists. I experienced same here: https://github.com/arburk/vscp/actions/runs/7776719404/job/21233496921 Disabling the cache works like charm: https://github.com/arburk/vscp/actions/runs/7790183588