Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

action not working on self hosted M1 machine #239

Closed
safa007 opened this issue Apr 6, 2022 · 14 comments
Closed

action not working on self hosted M1 machine #239

safa007 opened this issue Apr 6, 2022 · 14 comments

Comments

@safa007
Copy link

safa007 commented Apr 6, 2022

I'm curious if anyone has gotten this action to work with a self hosted m1 machine and arm64 emulator. I've been having a bunch of issues trying to get it to work.

My first issue is that when I try to run the action with api-level: 29 and arch: arm64-v8a without an emulator build, it gives me this error.

WARNING | unexpected system image feature string, emulator might not function correctly, please try updating the emulator.
  ERROR   | Unable to connect to adb daemon on port: 5037
  WARNING | cannot add library /Users/administrator/code/actions-runner/_work/marvin/marvin/undefined/emulator/qemu/darwin-aarch64/lib64/vulkan/libvulkan.dylib: failed
  ERROR   | EglOsGlLibrary: Could not open GL library libGLESv2.dylib [dlopen(libGLESv2.dylib, 0x0002): tried: '/Users/administrator/code/actions-runner/_work/marvin/marvin/undefined/emulator/lib64/gles_swiftshader/libGLESv2.dylib' (code signature in <B48F2D27-E9C4-30EF-A948-CB28819733C9> '/Users/administrator/code/actions-r]
  ERROR   | EglOsEglDispatcher: Could not open EGL library libEGL.dylib [dlopen(libEGL.dylib, 0x0002): tried: '/Users/administrator/code/actions-runner/_work/marvin/marvin/undefined/emulator/lib64/gles_swiftshader/libEGL.dylib' (code signature in <5C3ABCC5-722A-3AEA-AF5B-6CEEFF8D1074> '/Users/administrator/code/actions-runner/]

and the emulator hangs forever and doesn't start.

So, I added emulator-build: 8316981 to the args (emulator build 31.2.9) because I saw the error about the emulator needing to be updated. Which confuses me, because doesn't the action already use the latest emulator build? Well, now I'm getting a different error:

emulator: ERROR: process is translated under Rosetta. Attempting to replace emulator installation.
  emulator: Replacing via command: /Users/administrator/code/actions-runner/_work/marvin/marvin/undefined/emulator/darwin-aarch64-replace.sh (downloading ~120 MB)...
  sh: /Users/administrator/code/actions-runner/_work/marvin/marvin/undefined/emulator/darwin-aarch64-replace.sh: No such file or directory
  emulator: Replacement done. Please relaunch the emulator. You will also need to be using an Apple Silicon-compatible system image. Check the release updates blog (https://androidstudio.googleblog.com/) for more details.

and the emulator continues to hang.

I tracked the issue down here https://issuetracker.google.com/issues/226921798 and it seems like google is aware of that bug and will fix it in the next release. My question is, shouldn't the emulator launch regardless of this error? Or do I need to re-launch the emulator manually somehow?

I'm mainly posting this for visibility, but also to see if anyone has had success in running this action on a self hosted m1 machine. Any tips would be greatly appreciated.

@ychescale9
Copy link
Member

emulator-build is used for pinning the emulator binary to an old version and not use the latest.

If you want to try with the latest version in canary channel, add channel: canary to the config.

Not sure I can help with self-hosted / M1 issue so let's see if anyone else can chime in.

@safa007
Copy link
Author

safa007 commented Apr 6, 2022

Looks like the canary channel worked. Thanks for that recommendation 🙏

Another issue that I had to resolve was adding the ANDROID_SDK_ROOT as an environment variable to the self hosted machine, and the app built fine after that.

For anyone else that has an m1, my runner uses these arguments:

- name: run tests
  uses: reactivecircus/android-emulator-runner@v2
  with:
    api-level: 29
    arch: arm64-v8a
    profile: pixel_4a
    force-avd-creation: false
    emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
    channel: canary
    disable-animations: true

@ychescale9
Copy link
Member

Good to know it works. Using canary can mean your build is more likely to fail when Google pushes a new version with bugs/issues.

I'm planning to work on #226 to support pinning emulator and system image by using the semantic version of the release (replacing emulator-build), so you can more easily pin to a version that works for you and upgrade at your own pace.

@sebastianbuechler
Copy link

sebastianbuechler commented Aug 16, 2022

ANDROID_SDK_ROOT

@safa007 I'm missing the ANDROID_SDK_ROOT as well for this action.
PANIC: Cannot find AVD system path. Please define ANDROID_SDK_ROOT

How did you solve this for an M1 machine? Currently I have set it locally:

echo $ANDROID_SDK_ROOT
/Users/sebastianbuchler/Library/Android/sdk

@safa007
Copy link
Author

safa007 commented Aug 16, 2022

@sebastianbuechler use the android-actions/setup-android to install SDK tools, it'll automatically set the ANDROID_SDK_ROOT for you!

@sebastianbuechler
Copy link

@safa007 Thanks for that hint! I now encountered another issue with m1. Have you ever seen this error?

  Starting emulator.
  /bin/sh -c \/Users/sb/Library/Android/sdk/emulator/emulator -avd test -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none &
  INFO    | Android emulator version 31.3.10.0 (build_id 8807927) (CL:N/A)
  emulator: INFO: Found systemPath /Users/sb/Library/Android/sdk/system-images/android-29/default/x86/
  PANIC: Avd's CPU Architecture 'x86' is not supported by the QEMU2 emulator on aarch64 host.

It seems like the AVD's arch is somehow x86 but that's not compatible with arm?

My workflow file currently looks like this, can you spot anything wrong regarding the arch selections?

on:
  push:

name: Flutter integration test 
env:
  ANDROID_SDK_ROOT: /Users/sb/Library/Android/sdk
jobs:
  drive_android:
    runs-on: [self-hosted, macOS, ARM64]
    strategy:
      matrix:
        api-level: [29]
        target: [playstore]
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-java@v3
        with:
          distribution: temurin
          java-version: 11
      - uses: subosito/flutter-action@v2
        with:
          channel: "stable"
          flutter-version: "3.0.5"
          architecture: ARM64
      - 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-${{ 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:
          arch: arm64-v8a
          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 Flutter Driver tests
        uses: reactivecircus/android-emulator-runner@v2
        with:
          target: ${{ matrix.target }}
          api-level: ${{ matrix.api-level }}
          arch: arm64-v8a
          profile: Nexus 6
          script: flutter drive --driver=test_driver/integration_test.dart --target=integration_test/app_test.dart --flavor prod -d 'emulator'

@safa007
Copy link
Author

safa007 commented Aug 19, 2022

@sebastianbuechler I had to specify the canary channel when running with x64 architecture on M1s. Here's the setup that works for me.

      - name: create AVD
        uses: reactivecircus/android-emulator-runner@v2.25.0
        with:
          api-level: 29
          arch: arm64-v8a
          profile: pixel_5
          force-avd-creation: true
          emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
          channel: canary
          disable-animations: false
          script: echo "Generated AVD snapshot"

@sebastianbuechler
Copy link

@safa007 Thanks, but it still seems to have issues, even with canary:

  INFO    | Android emulator version 31.3.10.0 (build_id 8807927) (CL:N/A)
  emulator: INFO: Found systemPath /Users/sb/Library/Android/sdk/system-images/android-29/default/x86/
  PANIC: Avd's CPU Architecture 'x86' is not supported by the QEMU2 emulator on aarch64 host.

Do you have any other clues?

@Dambakk
Copy link

Dambakk commented Oct 4, 2022

I also have issues with running instrumentation tests on our self-hosted M1.

I install the android sdk using android-actions/setup-android as mentioned in previous comments. Then, my workflow looks like this:

      - name: Setup Android SDK
        uses: android-actions/setup-android@v2

      - name: Run tests
        uses: reactivecircus/android-emulator-runner@v2
        with:
          api-level: 31
          arch: arm64-v8a
          force-avd-creation: false
          disable-animations: true
          channel: canary
          emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
          script: ./gradlew connectedProdDebugAndroidTest

And I can see in the output that ANDROID_SDK_ROOT is set, but I still get an error indicating that something is wrong with that path.

Run reactivecircus/android-emulator-runner@v2
  with:
    api-level: 31
    arch: arm64-v8a
    force-avd-creation: false
    disable-animations: true
    channel: canary
    emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
    script: ./gradlew connectedProdDebugAndroidTest
    target: default
    cores: [2]
    avd-name: test
    disable-spellchecker: false
    disable-linux-hw-accel: auto
    enable-hw-keyboard: false
  env:
    JAVA_HOME: /Users/jenkins/actions-runner/_work/_tool/Java_Temurin-Hotspot_jdk/11.0.16-101/x64/Contents/Home
    JAVA_HOME_11_X64: /Users/jenkins/actions-runner/_work/_tool/Java_Temurin-Hotspot_jdk/11.0.16-101/x64/Contents/Home
    ANDROID_HOME: /Users/jenkins/.android/sdk
    ANDROID_SDK_ROOT: /Users/jenkins/.android/sdk
The node12 is not supported on macOS ARM64 platform. Use node16 instead.
Configure emulator
Install Android SDK
Launch Emulator
  /bin/sh -c \printf 'hw.cpu.ncore=2
  ' >> /Users/jenkins/.android/avd/test.avd/config.ini
  Starting emulator.
  /bin/sh -c \/Users/jenkins/.android/sdk/emulator/emulator -avd test -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none &
  WARNING | /Users/jenkins/.android/sdk/system-images/android-31/default/x86_64/ is not a valid directory.
  WARNING | emulator has searched the above paths but found no valid sdk root directory.
  PANIC: Broken AVD system path. Check your ANDROID_SDK_ROOT value [/Users/jenkins/.android/sdk]!
  INFO    | Android emulator version 32.1.1.0 (build_id 9037203) (CL:N/A)
  INFO    | AVD test has path /Users/jenkins/.android/avd/test.avd
  INFO    | trying to check whether /Users/jenkins/.android/sdk is a valid sdk root
  /Users/jenkins/.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/jenkins/.android/sdk/platform-tools/adb' failed with exit code 1
  /Users/jenkins/.android/sdk/platform-tools/adb shell getprop sys.boot_completed
  adb: no devices/emulators found
  The process '/Users/jenkins/.android/sdk/platform-tools/adb' failed with exit code 1
  /Users/jenkins/.android/sdk/platform-tools/adb shell getprop sys.boot_completed
  adb: no devices/emulators found
  The process '/Users/jenkins/.android/sdk/platform-tools/adb' failed with exit code 1
  /Users/jenkins/.android/sdk/platform-tools/adb shell getprop sys.boot_completed
 ...

I notice that I install an emulator with arm64-v8a architecture but that I get the warning /Users/jenkins/.android/sdk/system-images/android-31/default/x86_64/ is not a valid directory. mentioning a different architecture. Is that relevant, and how can I fix it?

@ychescale9
Copy link
Member

Are you sure default target is available with api 31? You might need to use google_apis or playstore instead.

@rjam
Copy link

rjam commented Dec 13, 2022

  INFO    | Android emulator version 31.3.10.0 (build_id 8807927) (CL:N/A)
  emulator: INFO: Found systemPath /Users/sb/Library/Android/sdk/system-images/android-29/default/x86/
  PANIC: Avd's CPU Architecture 'x86' is not supported by the QEMU2 emulator on aarch64 host.

@sebastianbuechler I get the exact same output even though I'm asking for an API 29 ARM64-v8a image. Did you manage to fix or find the root cause of this issue?

@rjam
Copy link

rjam commented Dec 13, 2022

Answering my own question from above. To fix:

  INFO    | Android emulator version 31.3.10.0 (build_id 8807927) (CL:N/A)
  emulator: INFO: Found systemPath /Users/sb/Library/Android/sdk/system-images/android-29/default/x86/
  PANIC: Avd's CPU Architecture 'x86' is not supported by the QEMU2 emulator on aarch64 host.

I had to start setting a custom avd-name that includes the target architecture (for example: macOS-avd-arm64-v8a-google_apis-29). Otherwise, all avds are being created with the same name - "test" (the default value) - and when the emulator is launched, that avd-name is used as the selector for which avd to use, so if we had a previous avd from a different architecture (e.g. x86), the emulator was picking that one up instead by default, instead of the one we just created with the arm64 image.

@Dambakk
Copy link

Dambakk commented Dec 15, 2022

☝️ Setting avd-name to something else than test worked for me too! 🎉

@IstrateAndreiTiny
Copy link

Specifying the channel: canary worked for me as well 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants