vgaidarji / android-github-actions

A GitHub action to build Android projects and run UI tests
Apache License 2.0
57 stars 11 forks source link

Failed to start emulator #11

Open noloman opened 5 years ago

noloman commented 5 years ago

Hi,

First of all, THANKS A LOT for creating this Github Action. I'm using it like:

    steps:
    - uses: actions/checkout@v1
    - name: set up JDK 1.8
      uses: actions/setup-java@v1
      with:
        java-version: 1.8
    - name: Build with Gradle
      run: ./gradlew build --stacktrace
    - name: Run Unit tests
      run: ./gradlew testDebugUnitTest
    - name: Run UI Tests
      uses: "vgaidarji/android-github-actions/emulator@v1.0.0"

but I'm getting this error:

Waiting for emulator to start
Emulator is ready
Android Emulator started after 184 seconds.

ERROR: JAVA_HOME is set to an invalid directory: /opt/hostedtoolcache/Java/8.0.222/x64

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.

##[error]Docker run failed with exit code 1
vgaidarji commented 5 years ago

@noloman hey. are you working on an open source project? if yes, could you please share a link to repository and failed actions build?

JAVA_HOME is set here https://github.com/vgaidarji/docker-android/blob/570d8f3aacd6af72b817254d08c99cd5bae57636/docker-android-build/Dockerfile#L5-L6 Not sure yet why it tells you that it is set to invalid directory /opt/hostedtoolcache/Java/8.0.222/x64.

noloman commented 5 years ago

@noloman hey. are you working on an open source project? if yes, could you please share a link to repository and failed actions build?

JAVA_HOME is set here vgaidarji/docker-android:docker-android-build/Dockerfile@570d8f3#L5-L6 Not sure yet why it tells you that it is set to invalid directory /opt/hostedtoolcache/Java/8.0.222/x64.

Hi, I'm using it in https://github.com/noloman/MoneyTransactions. Maybe it's because I'm setting it up wrong?

vgaidarji commented 5 years ago

@noloman I would advise you to get rid of set up JDK 1.8 step which actions/setup-java@v1 https://github.com/noloman/MoneyTransactions/blob/a296219512e96d68d9ddc57065d9d9f1ae5afe99/.github/workflows/android.yml#L15

And then use another action for running other Gradle tasks

    - name: Build with Gradle
      run: ./gradlew build --stacktrace
      uses: vgaidarji/android-github-actions/build@v1.0.0

Here's sample workflow I used to showcase GitHub Actions for Android project configuration - https://raw.githubusercontent.com/vgaidarji/ci-matters/master/.github/main.workflow.

mohsenoid commented 4 years ago

I am facing the same issue,

ERROR: JAVA_HOME is set to an invalid directory: /opt/hostedtoolcache/Java/8.0.232/x64

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.

Whole CI tasks and Android build works fine, but the moment I add the emulator it stopped working.

belafarinrod commented 4 years ago

Hey, I faced the same issue and tried to go with your workaround (replacing the jdk8-setup with your build step). This is my yml-file:

  steps:
    - uses: actions/checkout@v2
    - name: "Build"
      uses: vgaidarji/android-github-actions/build@v1.0.0
    - name: "Run UI Tests"
      uses: vgaidarji/android-github-actions-emulator@v1.0.1

Running the UI Tests fails:

/usr/bin/docker run --name d34243f0f986dd4a1c85843aeaf21cb61c_f345ca --label 3888d3 --workdir /github/workspace --rm -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/LazyAss/LazyAss":"/github/workspace" 3888d3:4243f0f986dd4a1c85843aeaf21cb61c
*************************************************************************
The "android" command is deprecated.
For manual SDK, AVD, and project management, please use Android Studio.
For command-line tools, use tools/bin/sdkmanager and tools/bin/avdmanager
*************************************************************************
Running /opt/android-sdk/tools/bin/avdmanager create avd --force -n test -t android-21 --abi default/armeabi-v7a

Error: Flag '-t' is not valid for 'create avd'.

Usage:
      avdmanager [global options] create avd [action options]
      Global options:
  -s --silent     : Silent mode, shows errors only.
  -v --verbose    : Verbose mode, shows errors, warnings and all messages.
     --clear-cache: Clear the SDK Manager repository manifest cache.
  -h --help       : Help on a specific command.

Action "create avd":
  Creates a new Android Virtual Device.
Options:
  -a --snapshot: Place a snapshots file in the AVD, to enable persistence.

This is the failing check: https://github.com/belafarinrod/LazyAss/pull/18/checks?check_run_id=725588657

vgaidarji commented 4 years ago

@belafarinrod hey. The issue you're facing has no resolution yet and is tracked under https://github.com/vgaidarji/docker-android/issues/11. You could try using alternative action in the meantime which uses mac-os runner instead of ubuntu where emulator is working. I did the same in here. Until https://github.com/google/android-emulator-container-scripts/issues/21 is solved, Android emulator action on Ubuntu won't work.