I have an android project and I am trying to run circleci locally. Most of it is going fine until I get to android/start-emulator-and-run-tests.
Here is my yaml:
# Use the latest 2.1 version of CircleCI pipeline process engine.
# See: https://circleci.com/docs/2.0/configuration-reference
# For a detailed guide to building and testing on Android, read the docs:
# https://circleci.com/docs/2.0/language-android/ for more details.
version: 2.1
# Orbs are reusable packages of CircleCI configuration that you may share across projects, enabling you to create encapsulated, parameterized commands, jobs, and executors that can be used across multiple projects.
# See: https://circleci.com/docs/2.0/orb-intro/
orbs:
android: circleci/android@2.0
gradle: circleci/gradle@2.2
# Define a job to be invoked later in a workflow.
# See: https://circleci.com/docs/2.0/configuration-reference/#jobs
jobs:
# Below is the definition of your job to build and test your app, you can rename and customize it as you want.
build-and-test:
docker:
- image: cimg/android:2022.07
auth:
username: ${DOCKER_USERNAME}
password: ${DOCKER_PASSWORD}
resource_class: large
# Add steps to the job
# See: https://circleci.com/docs/2.0/configuration-reference/#steps
steps:
# Checkout the code as the first step.
- checkout
# Setup files for build.
- run:
name: Setup variables for build
command: |
echo $GOOGLE_SERVICES_KEY_B64 | base64 --decode > app/google-services.json
- run:
name: Grant execute permission for gradlew
command: |
chmod +x gradlew
- gradle/with_cache:
steps:
- run:
name: Building the APK
command: ./gradlew -s assembleDriverDebug
# The next step will run the unit tests
- android/run-tests:
test-command: ./gradlew testDriverDebugUnitTest --continue
- android/save-gradle-cache:
cache-prefix: v1a
# Install Firebase tools needed for firebase emulator
- run:
name: Install firebase tools
command: |
curl -sL firebase.tools | bash
# Then start firebase emulator in the background
- run:
name: Start firebase emulator
command: |
firebase emulators:start
background: true
# Then start the emulator and run the Instrumentation tests!
- android/start-emulator-and-run-tests:
post-emulator-launch-assemble-command: ./gradlew assembleDriverDebugAndroidTest
test-command: ./gradlew connectedDriverDebugAndroidTest
system-image: system-images;android-25;google_apis;x86
# Then publish the artifacts of the Instrumentation tests!
- store_artifacts:
path: app/build/reports/androidTests/connected
destination: reports
# Then publish the artifacts of the Firebase emulator logs!
- run:
name: save firebase emulator logs
command: |
mkdir -p tmp/firebase_logs
cp *.log tmp/firebase_logs
- store_artifacts:
path: tmp/firebase_logs
destination: logs
# Then publish the results of the Instrumentation tests!
- store_test_results:
path: app/build/outputs/androidTest-results/connected
# Invoke jobs via workflows
# See: https://circleci.com/docs/2.0/configuration-reference/#workflows
workflows:
sample: # This is the name of the workflow, feel free to change it to better match your workflow.
# Inside the workflow, you define the jobs you want to run.
jobs:
- build-and-test
So all is good until it gets to android/start-emulator-and-run-tests. When its waiting for emulator it fails as its looking for “circle-android” but no command is found.
Here is the full error:
====>> Wait for the emulator to start
#!/bin/bash -eo pipefail
circle-android wait-for-boot/bin/bash: circle-android: command not found
Error:
Exited with code exit status 127Step failed
When I look at the documentation for android orb and look at the command for wait-for-boot:
description: |
Wait for the emulator to start.
Requires the "circle-android" script to be present in PATH.
steps:
- run:
command: |
circle-android wait-for-boot
name: Wait for the emulator to start
I have no idea how to set the “circle-android” script.