├── .circleci ├── config.yml └── test-deploy.yml ├── .github ├── CODEOWNERS ├── ISSUE_TEMPLATE.md └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── .yamllint ├── LICENSE ├── README.md └── src ├── @orb.yml ├── commands ├── accept_licenses.yml ├── change_java_version.yml ├── change_malloc.yml ├── create_avd.yml ├── create_google_play_key.yml ├── create_keystore_properties.yml ├── decode_keystore.yml ├── disable_animations.yml ├── fastlane_deploy.yml ├── install_ndk.yml ├── kill_emulators.yml ├── restore_build_cache.yml ├── restore_gradle_cache.yml ├── run_tests.yml ├── save_build_cache.yml ├── save_gradle_cache.yml ├── start_emulator.yml ├── start_emulator_and_run_tests.yml └── wait_for_emulator.yml ├── examples ├── granular_commands.yml ├── override_machine_resource_class.yml ├── run_ui_tests_job.yml ├── start_emulator_and_run_tests.yml └── test_matrix.yml ├── executors ├── android_docker.yml └── android_machine.yml ├── jobs ├── build.yml ├── deploy_to_play_store.yml └── run_ui_tests.yml └── scripts ├── change_java_version.sh ├── change_malloc_implementation.sh ├── create_avd.sh ├── create_keystore_properties.sh ├── decode_keystore.sh ├── disable_animations.sh ├── generate_cache_checksum.sh ├── install_ndk.sh ├── kill_emulators.sh ├── run_tests.sh └── start_emulator.sh /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2.1 2 | setup: true 3 | orbs: 4 | orb-tools: circleci/orb-tools@12.1 5 | shellcheck: circleci/shellcheck@3.1 6 | 7 | filters: &filters 8 | tags: 9 | only: /.*/ 10 | 11 | workflows: 12 | lint-pack: 13 | jobs: 14 | - orb-tools/lint: 15 | filters: *filters 16 | - orb-tools/pack: 17 | filters: *filters 18 | - orb-tools/review: 19 | filters: *filters 20 | - shellcheck/check: 21 | exclude: SC2148,SC2038,SC2086,SC2002,SC2016 22 | filters: *filters 23 | - orb-tools/continue: 24 | orb_name: android 25 | pipeline_number: << pipeline.number >> 26 | vcs_type: << pipeline.project.type >> 27 | requires: [orb-tools/lint, orb-tools/pack, orb-tools/review, shellcheck/check] 28 | filters: *filters 29 | -------------------------------------------------------------------------------- /.circleci/test-deploy.yml: -------------------------------------------------------------------------------- 1 | version: 2.1 2 | orbs: 3 | android: {} 4 | node: circleci/node@6.1.0 5 | orb-tools: circleci/orb-tools@12.1.0 6 | filters: &filters 7 | tags: 8 | only: /.*/ 9 | prod-deploy-requires: &prod-deploy-requires 10 | [ 11 | orb-tools/pack, 12 | ui-tests-jetchat, 13 | test_start_emulator_and_run_tests, test_java_version 14 | ] 15 | jobs: 16 | test_java_version: 17 | parameters: 18 | executor: 19 | type: executor 20 | description: | 21 | Which Android image/executor to use. Choose between 'android_docker' 22 | and 'android_machine'. 23 | java_version: 24 | type: integer 25 | description: | 26 | Version to use in the change_java_version job 27 | executor: <> 28 | steps: 29 | - checkout 30 | - android/change_java_version: 31 | java_version: << parameters.java_version >> 32 | - run: 33 | command: | 34 | JAVA_VER="$( java -version 2>&1 | head -1 | cut -d'"' -f2 | sed '/^1\./s///' | cut -d'.' -f1 )" 35 | JAVAC_VER="$( javac -version 2>&1 | head -1 | cut -f 2- -d ' ' | sed '/^1\./s///' | cut -d'.' -f1 )" 36 | if [ "$JAVA_VER" -ne <> ]; then 37 | echo "Job failed because java version was not changed." 38 | echo "current java version:" $JAVA_VER 39 | exit 1 40 | fi 41 | if [ "$JAVAC_VER" -ne <> ]; then 42 | echo "Job failed because javac version was not changed." 43 | echo "current javac version:" $JAVAC_VER 44 | exit 1 45 | fi 46 | name: check for correctness 47 | test-ndk-install: 48 | parameters: 49 | executor: 50 | type: executor 51 | description: | 52 | Which Android image/executor to use. Choose between 'android_docker' 53 | and 'android_machine'. 54 | ndk: 55 | type: string 56 | description: ndk version to install 57 | executor: << parameters.executor >> 58 | steps: 59 | - checkout 60 | - android/install_ndk: 61 | version: << parameters.ndk >> 62 | test-emulator-commands: 63 | parameters: 64 | system_image: 65 | type: string 66 | tag: 67 | type: string 68 | description: "Android machine image tag to use." 69 | executor: 70 | name: android/android_machine 71 | tag: << parameters.tag >> 72 | steps: 73 | - checkout 74 | - run: 75 | name: Clone project 76 | command: | 77 | git clone https://github.com/android/compose-samples 78 | cd compose-samples 79 | # pin the revision for consistency 80 | git checkout 5b9a06f39fe3656f05d5169b6d63086573b91754 81 | - android/create_avd: 82 | avd_name: test1 83 | system_image: <> 84 | install: true 85 | - android/start_emulator: 86 | avd_name: test1 87 | run_logcat: true 88 | memory: 3072 89 | restore_gradle_cache_prefix: v1-multiple 90 | post_emulator_launch_assemble_command: "cd compose-samples/Reply && ./gradlew assembleDebugAndroidTest" 91 | - android/run_tests: 92 | working_directory: ./compose-samples/Reply 93 | pre_test_command: "./gradlew tasks" 94 | - android/save_gradle_cache: 95 | cache_prefix: v1-multiple 96 | - android/kill_emulators 97 | - run: sdkmanager "system-images;android-31;default;x86_64" 98 | - android/create_avd: 99 | avd_name: test2 100 | system_image: system-images;android-31;default;x86_64 101 | install: false 102 | - android/start_emulator: 103 | avd_name: test2 104 | # we expect the no_window parameter to be overridden by override_args 105 | no_window: true 106 | override_args: "-delay-adb -verbose -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim" 107 | wait_for_emulator: true 108 | restore_gradle_cache_post_emulator_launch: false 109 | post_emulator_launch_assemble_command: "" 110 | disable_animations: false 111 | pre_emulator_wait_steps: 112 | - run: 113 | name: Dummy pre_emulator_wait_steps 114 | command: | 115 | echo "Test" 116 | post_emulator_wait_steps: 117 | - run: 118 | name: Dummy post_emulator_wait_steps 119 | command: | 120 | echo "Test" 121 | - android/kill_emulators 122 | - android/create_avd: 123 | avd_name: test3 124 | system_image: system-images;android-31;default;x86_64 125 | install: true 126 | background: true 127 | - run: sleep 15 && echo "should cancel previous command" 128 | test_start_emulator_and_run_tests: 129 | parameters: 130 | tag: 131 | type: string 132 | description: "Android machine image tag to use." 133 | args: 134 | type: string 135 | default: "" 136 | description: Additional args to pass to avd creation 137 | executor: 138 | name: android/android_machine 139 | tag: << parameters.tag >> 140 | resource_class: xlarge 141 | steps: 142 | - checkout 143 | - android/start_emulator_and_run_tests: 144 | pre_emulator_wait_steps: 145 | - run: 146 | name: Clone project 147 | command: | 148 | git clone https://github.com/android/compose-samples 149 | cd compose-samples 150 | # pin the revision for consistency 151 | git checkout 5b9a06f39fe3656f05d5169b6d63086573b91754 152 | - android/restore_build_cache 153 | - run: cd compose-samples/Jetchat && ./gradlew assembleDebugAndroidTest 154 | post_emulator_launch_assemble_command: "" 155 | additional_avd_args: <> 156 | run_tests_working_directory: ./compose-samples/Jetchat 157 | post_run_tests_steps: 158 | - android/save_build_cache 159 | pull_data: true 160 | pull_data_path: storage 161 | pull_data_target: "." 162 | test-fastlane: 163 | docker: 164 | - image: cimg/android:2022.07 165 | resource_class: large 166 | steps: 167 | - checkout 168 | - run: 169 | name: clone sample project 170 | command: git clone git@github.com:CircleCI-Public/ReactNativeCFD.git 171 | - node/install: 172 | install-yarn: false 173 | node-version: "16.13.0" 174 | - run: cd ReactNativeCFD && npm install 175 | - android/decode_keystore: 176 | keystore_location: ReactNativeCFD/android/app/keystore 177 | - android/create_keystore_properties: 178 | working_directory: ReactNativeCFD/android 179 | - android/create_google_play_key: 180 | working_directory: ReactNativeCFD/android 181 | - android/fastlane_deploy: 182 | working_directory: ReactNativeCFD/android 183 | lane_name: list 184 | test-malloc: 185 | docker: 186 | - image: cimg/android:2023.06 187 | resource_class: medium 188 | steps: 189 | - checkout 190 | - android/change_malloc 191 | - run: 192 | name: check malloc override to jemalloc 193 | command: cat /etc/environment | grep jemalloc 194 | - run: 195 | name: check jemalloc size 196 | command: sudo apt show libjemalloc-dev | grep Size 197 | - android/change_malloc: 198 | implementation: tcmalloc 199 | - run: 200 | name: check malloc override to tcmalloc 201 | command: cat /etc/environment | grep tcmalloc 202 | - run: 203 | name: check tcmalloc size 204 | command: sudo apt show google-perftools | grep Size 205 | workflows: 206 | test-deploy: 207 | jobs: 208 | - test-malloc: 209 | name: "Test Changing Malloc Implementations" 210 | - test_java_version: 211 | name: "Test OpenJDK version change" 212 | executor: 213 | name: android/android_docker 214 | tag: "2023.05.1" 215 | matrix: 216 | parameters: 217 | java_version: 218 | - 8 219 | - 11 220 | - 17 221 | - 18 222 | - 21 223 | filters: *filters 224 | - test-ndk-install: 225 | name: "Test NDK Install on Android Docker" 226 | matrix: 227 | parameters: 228 | executor: 229 | - name: android/android_docker 230 | tag: "2021.10.1" 231 | - name: android/android_docker 232 | tag: "2021.09.1" 233 | ndk: 234 | - "23.0.7599858" 235 | - "21.4.7075529" 236 | - "19.2.5345600" 237 | - "27.1.12297006" 238 | filters: *filters 239 | - test-ndk-install: 240 | name: "Test NDK Install on Android Machine" 241 | executor: 242 | name: android/android_machine 243 | tag: "default" 244 | matrix: 245 | parameters: 246 | ndk: 247 | - "23.0.7599858" 248 | - "21.4.7075529" 249 | - "19.2.5345600" 250 | - "27.1.12297006" 251 | filters: *filters 252 | - android/run_ui_tests: 253 | name: "ui-tests-jetchat-<>" 254 | executor: 255 | name: android/android_machine 256 | tag: "default" 257 | checkout: false 258 | max_tries: 4 259 | pre-steps: 260 | - run: 261 | name: Setup project 262 | command: | 263 | git clone https://github.com/android/compose-samples 264 | cd compose-samples 265 | # pin the revision for consistency 266 | git checkout 5b9a06f39fe3656f05d5169b6d63086573b91754 267 | cd .. 268 | cp -r compose-samples/Jetchat/* . 269 | rm -rf compose-samples 270 | matrix: 271 | alias: ui-tests-jetchat 272 | parameters: 273 | system_image: ["system-images;android-31;default;x86_64", "system-images;android-30;default;x86_64"] 274 | filters: *filters 275 | # - test-emulator-commands: 276 | # system_image: "system-images;android-31;default;x86_64" 277 | # tag: "default" 278 | # filters: *filters 279 | - test_start_emulator_and_run_tests: 280 | name: test_start_emulator_and_run_tests 281 | tag: "default" 282 | filters: *filters 283 | - test_start_emulator_and_run_tests: 284 | name: test_start_emulator_and_run_tests-with-args 285 | tag: "default" 286 | args: -d pixel_6 287 | filters: *filters 288 | - test-fastlane 289 | - orb-tools/pack: 290 | filters: *filters 291 | - orb-tools/publish: 292 | orb_name: circleci/android 293 | vcs_type: << pipeline.project.type >> 294 | pub_type: production 295 | requires: *prod-deploy-requires 296 | context: orb-publisher 297 | filters: 298 | branches: 299 | ignore: /.*/ 300 | tags: 301 | only: /^v[0-9]+\.[0-9]+\.[0-9]+$/ 302 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @CircleCI-Public/orb-publishers 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### Orb version 2 | 3 | 10 | 11 | ### What happened 12 | 13 | 17 | 18 | ### Expected behavior 19 | 20 | 21 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### Checklist 2 | 3 | 8 | 9 | - [ ] All new jobs, commands, executors, parameters have descriptions 10 | - [ ] Examples have been added for any significant new features 11 | - [ ] README has been updated, if necessary 12 | 13 | ### Motivation, issues 14 | 15 | 20 | 21 | ### Description 22 | 23 | 27 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | orb.yml -------------------------------------------------------------------------------- /.yamllint: -------------------------------------------------------------------------------- 1 | extends: relaxed 2 | 3 | rules: 4 | line-length: 5 | max: 200 6 | allow-non-breakable-inline-mappings: true -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright ©2021 CircleCI 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Android Orb [![CircleCI Build Status](https://circleci.com/gh/CircleCI-Public/android-orb.svg?style=shield "CircleCI Build Status")](https://app.circleci.com/pipelines/github/CircleCI-Public/android-orb) [![CircleCI Orb Version](https://badges.circleci.com/orbs/circleci/android.svg)](https://circleci.com/developer/orbs/orb/circleci/android) [![GitHub License](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/CircleCI-Public/android-orb/main/LICENSE) [![CircleCI Community](https://img.shields.io/badge/community-CircleCI%20Discuss-343434.svg)](https://discuss.circleci.com/c/ecosystem/orbs) 2 | 3 | An orb for working with Android on CircleCI. Supports running UI tests 4 | that use the Android emulator, using the Android machine image which is 5 | currently in preview status: https://github.com/CircleCI-Public/android-image-preview-docs 6 | 7 | ## Usage 8 | 9 | For full usage guidelines, see the [orb registry listing](https://circleci.com/developer/orbs/orb/circleci/android). 10 | 11 | ## Documentation 12 | 13 | See the following links for more information about building Android projects on CircleCI. 14 | 15 | - https://circleci.com/docs/2.0/language-android 16 | - https://github.com/CircleCI-Public/circleci-demo-react-native 17 | 18 | See the following links for more information about using CircleCI orbs: 19 | 20 | - https://circleci.com/orbs 21 | - https://circleci.com/docs/2.0/using-orbs 22 | - https://circleci.com/docs/2.0/reusing-config 23 | - https://circleci.com/docs/2.0/orbs-faq 24 | 25 | ## Contributing 26 | 27 | We welcome [issues](https://github.com/CircleCI-Public/android-orb/issues) to and [pull requests](https://github.com/CircleCI-Public/android-orb/pulls) against this repository! 28 | 29 | For further questions/comments about this or other orbs, visit [CircleCI's orbs discussion forum](https://discuss.circleci.com/c/orbs). 30 | -------------------------------------------------------------------------------- /src/@orb.yml: -------------------------------------------------------------------------------- 1 | description: | 2 | Orb for working with Android projects on CircleCI. 3 | Supports running Android emulator UI tests. 4 | display: 5 | source_url: https://github.com/circleci-public/android-orb 6 | version: 2.1 7 | -------------------------------------------------------------------------------- /src/commands/accept_licenses.yml: -------------------------------------------------------------------------------- 1 | description: > 2 | Accept all Android SDK Manager licenses 3 | 4 | steps: 5 | - run: 6 | name: Accept Android Licenses 7 | shell: /bin/bash -e 8 | description: > 9 | Accepts all Android SDK licenses. 10 | This command is typically not necessary to execute, since the CircleCI machine/convenience images 11 | ship with all licenses accepted. 12 | This command will add approximately 10 seconds to the build time. 13 | # Use a custom shell. 14 | # We don't `set -o pipefail` since sdkmanager does not interact nicely 15 | # with the incoming pipe, which can result in the `yes` command exiting with code 147. 16 | command: | 17 | yes | sdkmanager --licenses 18 | yes | sdkmanager --update 19 | -------------------------------------------------------------------------------- /src/commands/change_java_version.yml: -------------------------------------------------------------------------------- 1 | description: | 2 | Change default java version from OpenJDK v17. 3 | parameters: 4 | java_version: 5 | type: integer 6 | default: 8 7 | description: | 8 | The version of OpenJDK to change to 9 | steps: 10 | - run: 11 | environment: 12 | PARAM_JAVA_VER: << parameters.java_version >> 13 | name: Change OpenJDK version to << parameters.java_version >> 14 | command: <> 15 | -------------------------------------------------------------------------------- /src/commands/change_malloc.yml: -------------------------------------------------------------------------------- 1 | description: | 2 | Change default malloc from glibc malloc to jemalloc 3 | parameters: 4 | implementation: 5 | type: enum 6 | default: jemalloc 7 | enum: [jemalloc, tcmalloc] 8 | steps: 9 | - run: 10 | environment: 11 | PARAM_IMPLEMENTATION: << parameters.implementation >> 12 | name: change malloc implementation to << parameters.implementation >> 13 | command: <> 14 | -------------------------------------------------------------------------------- /src/commands/create_avd.yml: -------------------------------------------------------------------------------- 1 | description: | 2 | Create an AVD. 3 | parameters: 4 | avd_name: 5 | type: string 6 | description: | 7 | The name of the AVD to create. 8 | You can pass environment variables, using the $ syntax e.g. "$AVD_NAME" 9 | system_image: 10 | type: string 11 | description: | 12 | Name of system image e.g. "system-images;android-29;default;x86". 13 | It should match the name seen in the "sdkmanager --list" output. 14 | You can pass environment variables, using the $ syntax e.g. "$SYSTEM_IMAGE" 15 | install: 16 | type: boolean 17 | description: | 18 | Whether to first install the system image via sdkmanager 19 | background: 20 | type: boolean 21 | description: | 22 | Whether to run the creation command in background 23 | default: false 24 | additional_args: 25 | type: string 26 | default: "" 27 | description: | 28 | Additional args to be passed directly to the avd creation command 29 | You can pass environment variables, using the $ syntax e.g. "$ADDITIONAL_ARGS" 30 | steps: 31 | - run: 32 | environment: 33 | PARAM_AVD_NAME: << parameters.avd_name >> 34 | PARAM_INSTALL: << parameters.install >> 35 | PARAM_SYSTEM_IMAGE: << parameters.system_image >> 36 | PARAM_ADDITIONAL_ARGS: << parameters.additional_args >> 37 | name: Create avd "<< parameters.avd_name >>" 38 | command: <> 39 | background: << parameters.background >> 40 | -------------------------------------------------------------------------------- /src/commands/create_google_play_key.yml: -------------------------------------------------------------------------------- 1 | description: | 2 | Generate JSON file for your google play key. For use with environment variables. 3 | parameters: 4 | google_play_key: 5 | description: Your google play key 6 | type: env_var_name 7 | default: GOOGLE_PLAY_KEY 8 | working_directory: 9 | description: Working directory to create google play key in 10 | type: string 11 | default: "." 12 | steps: 13 | - run: 14 | name: Create Google Play key 15 | command: echo ${<< parameters.google_play_key >>} > google-play-key.json 16 | working_directory: << parameters.working_directory >> 17 | -------------------------------------------------------------------------------- /src/commands/create_keystore_properties.yml: -------------------------------------------------------------------------------- 1 | description: | 2 | Creates a keystore.properties file for use in deployment steps. For use with environment variables. 3 | parameters: 4 | release_key_alias: 5 | description: Release key alias 6 | type: env_var_name 7 | default: RELEASE_KEY_ALIAS 8 | release_key_password: 9 | description: Password for your release key 10 | type: env_var_name 11 | default: RELEASE_KEY_PASSWORD 12 | release_keystore: 13 | description: Points to the location of your decrypted keystore 14 | type: string 15 | default: ./keystore 16 | release_store_password: 17 | description: Password for your keystore 18 | type: env_var_name 19 | default: RELEASE_STORE_PASSWORD 20 | working_directory: 21 | description: Working directory to create keystore.properties in 22 | type: string 23 | default: "." 24 | steps: 25 | - run: 26 | environment: 27 | PARAM_RELEASE_KEY_ALIAS: << parameters.release_key_alias >> 28 | PARAM_RELEASE_KEY_PASSWORD: << parameters.release_key_password >> 29 | PARAM_RELEASE_KEYSTORE: << parameters.release_keystore >> 30 | PARAM_RELEASE_STORE_PASSWORD: << parameters.release_store_password >> 31 | name: Create keystore.properties 32 | command: <> 33 | working_directory: << parameters.working_directory >> 34 | -------------------------------------------------------------------------------- /src/commands/decode_keystore.yml: -------------------------------------------------------------------------------- 1 | description: | 2 | Decodes a keystore that was encrypted in base64. For use with environment variables. 3 | parameters: 4 | base64_keystore: 5 | description: Your base64 keystore 6 | type: env_var_name 7 | default: BASE64_KEYSTORE 8 | keystore_location: 9 | description: The location of your decrypted keystore 10 | type: string 11 | default: '.' 12 | steps: 13 | - run: 14 | environment: 15 | PARAM_BASE64_KEYSTORE: << parameters.base64_keystore >> 16 | PARAM_KEYSTORE_LOCATION: << parameters.keystore_location >> 17 | name: Decode Keystore 18 | command: <> 19 | -------------------------------------------------------------------------------- /src/commands/disable_animations.yml: -------------------------------------------------------------------------------- 1 | description: | 2 | Disables animations. Requires an emulator to be running. 3 | steps: 4 | - run: 5 | name: Disable emulator animations 6 | command: <> 7 | -------------------------------------------------------------------------------- /src/commands/fastlane_deploy.yml: -------------------------------------------------------------------------------- 1 | description: | 2 | Runs fastlane lanes to deploy to Google Play Store 3 | parameters: 4 | working_directory: 5 | description: Working directory to run fastlane commands in 6 | type: string 7 | default: "." 8 | lane_name: 9 | description: The name of the lane fastlane will execute 10 | type: string 11 | default: "deploy" 12 | steps: 13 | - run: 14 | name: Run fastlane 15 | command: fastlane << parameters.lane_name >> 16 | working_directory: << parameters.working_directory >> 17 | -------------------------------------------------------------------------------- /src/commands/install_ndk.yml: -------------------------------------------------------------------------------- 1 | description: | 2 | Install an Android NDK version using 'sdkmanager'. This command takes one 3 | parameter called 'ndk', which is the NDK version. If the version is already 4 | available, the step will still complete successfully. 5 | 6 | This command is designed to be used with the CircleCI Android Docker or 7 | machine images. 8 | 9 | Available NDK versions can be found here: 10 | https://github.com/android/compose-samples 11 | 12 | parameters: 13 | version: 14 | type: string 15 | description: | 16 | Version of the NDK to install. Available NDK versions can be found here: 17 | https://github.com/android/compose-samples 18 | 19 | steps: 20 | - run: 21 | environment: 22 | PARAM_VER: << parameters.version >> 23 | name: Install Android NDK 24 | command: <> 25 | -------------------------------------------------------------------------------- /src/commands/kill_emulators.yml: -------------------------------------------------------------------------------- 1 | description: | 2 | Terminates any running emulator processes 3 | steps: 4 | - run: 5 | name: Kill any running emulators 6 | command: <> 7 | -------------------------------------------------------------------------------- /src/commands/restore_build_cache.yml: -------------------------------------------------------------------------------- 1 | description: > 2 | Restore the build cache. See `save_build_cache` for more information. 3 | 4 | parameters: 5 | cache_prefix: 6 | description: Used to form part of the cache key 7 | type: string 8 | default: v1 9 | 10 | steps: 11 | - restore_cache: 12 | name: Restore build cache 13 | key: android-orb-<> 14 | -------------------------------------------------------------------------------- /src/commands/restore_gradle_cache.yml: -------------------------------------------------------------------------------- 1 | description: | 2 | Restore gradle cache 3 | parameters: 4 | cache_prefix: 5 | description: Used to form part of the cache key 6 | type: string 7 | default: v1 8 | find_args: 9 | description: | 10 | Use this to customize how the find command is used to look for relevant 11 | file changes. 12 | type: string 13 | default: ". -name \"build.gradle*\" -o -name \"settings.gradle*\"" 14 | steps: 15 | - run: 16 | environment: 17 | PARAM_FIND_ARGS: << parameters.find_args >> 18 | name: Generate cache checksum 19 | command: <> 20 | - restore_cache: 21 | name: Restore gradle cache 22 | key: gradle-<< parameters.cache_prefix>>-{{ arch }}-{{ checksum "/tmp/gradle_cache_seed" }} 23 | -------------------------------------------------------------------------------- /src/commands/run_tests.yml: -------------------------------------------------------------------------------- 1 | description: | 2 | Runs tests, with retries supported 3 | parameters: 4 | pre_test_command: 5 | description: | 6 | Command to run prior to runnning the test command 7 | You can pass environment variables, using the $ syntax e.g. "$PRE_TEST_COMMAND" 8 | type: string 9 | default: " " 10 | test_command: 11 | description: | 12 | Command to run in order to run the tests 13 | You can pass environment variables, using the $ syntax e.g. "$TEST_COMMAND" 14 | type: string 15 | default: "./gradlew connectedDebugAndroidTest" 16 | working_directory: 17 | description: Working directory to run the tests in 18 | type: string 19 | default: "." 20 | max_tries: 21 | description: Max number of tries. To disable retries, set this to 1. 22 | type: integer 23 | default: 2 24 | retry_interval: 25 | description: Duration in seconds to wait before the next try 26 | type: integer 27 | default: 5 28 | no_output_timeout: 29 | description: Use this to configure the no_output_timeout value 30 | type: string 31 | default: 10m 32 | pull_data: 33 | description: | 34 | Whether to pull data after running tests 35 | type: boolean 36 | default: false 37 | pull_data_path: 38 | description: | 39 | Emulator directory to pull data from 40 | type: string 41 | default: data 42 | pull_data_target: 43 | description: | 44 | Location to save pulled data 45 | type: string 46 | default: "." 47 | steps: 48 | - run: 49 | environment: 50 | PARAM_MAX_TRIES: << parameters.max_tries >> 51 | PARAM_TEST_COMMAND: << parameters.test_command >> 52 | PARAM_PRE_TEST_COMMAND: << parameters.pre_test_command >> 53 | PARAM_RETRY_INTERVAL: << parameters.retry_interval >> 54 | name: Run tests with max tries of <> 55 | working_directory: <> 56 | no_output_timeout: <> 57 | command: <> 58 | - when: 59 | condition: << parameters.pull_data >> 60 | steps: 61 | - run: adb pull << parameters.pull_data_path >> << parameters.pull_data_target >> 62 | -------------------------------------------------------------------------------- /src/commands/save_build_cache.yml: -------------------------------------------------------------------------------- 1 | description: > 2 | Save the Android build-cache. 3 | The build cache stores certain outputs that the Android plugin for Gradle 4 | generates when building your project (such as unpackaged AARs and pre-dexed 5 | remote dependencies). Your clean builds are much faster while using the 6 | cache because the build system can simply reuse those cached files during 7 | subsequent builds, instead of recreating them. The build cache also works 8 | on continuous integration servers and when running multiple build processes 9 | on a single local machine. 10 | 11 | See https://developer.android.com/studio/build/build-cache 12 | 13 | parameters: 14 | cache_prefix: 15 | description: Used to form part of the cache key 16 | type: string 17 | default: v1 18 | 19 | steps: 20 | - save_cache: 21 | name: Save build cache 22 | key: android-orb-<> 23 | paths: 24 | - ~/.android/build-cache 25 | - ~/.android/cache 26 | -------------------------------------------------------------------------------- /src/commands/save_gradle_cache.yml: -------------------------------------------------------------------------------- 1 | description: | 2 | Save gradle cache 3 | parameters: 4 | cache_prefix: 5 | description: Used to form part of the cache key 6 | type: string 7 | default: v1 8 | steps: 9 | - save_cache: 10 | name: Save gradle cache 11 | key: gradle-<< parameters.cache_prefix>>-{{ arch }}-{{ checksum "/tmp/gradle_cache_seed" }} 12 | paths: 13 | - ~/.gradle/caches 14 | - ~/.gradle/wrapper 15 | - .gradle/configuration-cache 16 | -------------------------------------------------------------------------------- /src/commands/start_emulator.yml: -------------------------------------------------------------------------------- 1 | description: | 2 | Start an emulator as a background process. 3 | The AVD used should already be created. (See "create_avd" command for how 4 | one could be created) 5 | parameters: 6 | avd_name: 7 | description: | 8 | The name of the existing AVD to use for the emulator 9 | type: string 10 | gpu: 11 | description: | 12 | The value to use for the "-gpu" flag. 13 | If set to "", the emulator will be run without the -gpu flag. 14 | type: string 15 | default: "swiftshader_indirect" 16 | camera_front: 17 | description: | 18 | The value to use for the "-camera-front" flag. 19 | If set to "", the emulator will be run without the -camera-front flag. 20 | type: string 21 | default: "" 22 | camera_back: 23 | description: | 24 | The value to use for the "-camera-back" flag. 25 | If set to "", the emulator will be run without the -camera-back flag. 26 | type: string 27 | default: "" 28 | memory: 29 | description: | 30 | The value to use for the "-memory" flag. 31 | If set to -1, the emulator will be run without the -memory flag. 32 | type: integer 33 | default: -1 34 | no_window: 35 | description: | 36 | Whether to run the emulator with the -no-window flag 37 | type: boolean 38 | default: true 39 | no_audio: 40 | description: | 41 | Whether to run the emulator with the -noaudio flag 42 | type: boolean 43 | default: true 44 | no_boot_anim: 45 | description: | 46 | Whether to run the emulator with the -no-boot-anim flag 47 | type: boolean 48 | default: true 49 | no_snapshot: 50 | description: | 51 | Whether to run the emulator with the -no-snapshot flag 52 | type: boolean 53 | default: true 54 | delay_adb: 55 | description: | 56 | Whether to run the emulator with the -delay-adb flag 57 | type: boolean 58 | default: false 59 | verbose: 60 | description: | 61 | Whether to run the emulator with the -verbose flag 62 | type: boolean 63 | default: true 64 | additional_args: 65 | description: | 66 | Additional args to be passed directly to the emulator command 67 | type: string 68 | default: "" 69 | override_args: 70 | description: | 71 | If this is set to a non-blank value, the emulator command will be 72 | run with the -avd flag and the value of "override_args" (i.e. none of the defaults 73 | provided by the orb command will be used) 74 | type: string 75 | default: "" 76 | pre_emulator_wait_steps: 77 | description: | 78 | Steps to execute while before beginning to wait for the emulator to start up 79 | type: steps 80 | default: [] 81 | post_emulator_launch_assemble_command: 82 | description: | 83 | If this is set to a non-blank value, the configured command will be run 84 | after the emulator has been launched, and before commencing the 85 | wait for the emulator to finish starting up. 86 | type: string 87 | default: "./gradlew assembleDebugAndroidTest" 88 | restore_gradle_cache_post_emulator_launch: 89 | description: | 90 | Whether to restore the gradle cache after the emulator has been launched, 91 | and before commencing the wait for the emulator to finish starting up. 92 | type: boolean 93 | default: true 94 | restore_gradle_cache_prefix: 95 | description: | 96 | Cache prefix used if the "restore_gradle_cache_post_emulator_launch" parameter 97 | is set to true. 98 | type: string 99 | default: "v1" 100 | restore_gradle_cache_find_args: 101 | description: | 102 | Use this to customize how the find command is used to look for relevant 103 | file changes. 104 | type: string 105 | default: ". -name \"build.gradle*\" -o -name \"settings.gradle*\"" 106 | post_emulator_wait_steps: 107 | description: | 108 | Steps to execute after waiting for the emulator to start up 109 | type: steps 110 | default: [] 111 | wait_for_emulator: 112 | description: | 113 | Whether to wait for the emulator to start up 114 | type: boolean 115 | default: true 116 | run_logcat: 117 | description: | 118 | Whether to run with logcat in the background, after the emulator starts up 119 | type: boolean 120 | default: false 121 | disable_animations: 122 | description: | 123 | Whether to disable animations that may interfere with tests, after the emulator starts up 124 | type: boolean 125 | default: true 126 | steps: 127 | - run: 128 | environment: 129 | PARAM_OVERRIDE_ARGS: << parameters.override_args >> 130 | PARAM_AVD_NAME: << parameters.avd_name >> 131 | PARAM_NO_WINDOW: << parameters.no_window >> 132 | PARAM_NO_AUDIO: << parameters.no_audio >> 133 | PARAM_NO_BOOT_ANIM: << parameters.no_boot_anim >> 134 | PARAM_VERBOSE: << parameters.verbose >> 135 | PARAM_NO_SNAPSHOT: << parameters.no_snapshot >> 136 | PARAM_DELAY_ABD: << parameters.delay_adb >> 137 | PARAM_MEMORY: << parameters.memory >> 138 | PARAM_GPU: << parameters.gpu >> 139 | PARAM_CAMERA_FRONT: << parameters.camera_front >> 140 | PARAM_CAMERA_BACK: << parameters.camera_back >> 141 | PARAM_ADDITIONAL_ARGS: << parameters.additional_args >> 142 | name: Start emulator 143 | command: <> 144 | background: true 145 | - when: 146 | condition: 147 | and: 148 | - << parameters.restore_gradle_cache_post_emulator_launch >> 149 | - equal: [ true, << parameters.wait_for_emulator >> ] 150 | steps: 151 | - restore_gradle_cache: 152 | cache_prefix: << parameters.restore_gradle_cache_prefix >> 153 | find_args: << parameters.restore_gradle_cache_find_args >> 154 | - when: 155 | condition: 156 | and: 157 | - << parameters.post_emulator_launch_assemble_command >> 158 | - equal: [ true, << parameters.wait_for_emulator >> ] 159 | steps: 160 | - run: 161 | name: "Run: << parameters.post_emulator_launch_assemble_command >>" 162 | command: | 163 | # This is meant to do something useful in parallel with the emulator 164 | # starting up, like assembling the app, which is required for UI tests 165 | << parameters.post_emulator_launch_assemble_command >> 166 | - when: 167 | condition: << parameters.wait_for_emulator >> 168 | steps: 169 | - << parameters.pre_emulator_wait_steps >> 170 | - when: 171 | condition: << parameters.wait_for_emulator >> 172 | steps: 173 | - wait_for_emulator 174 | - when: 175 | condition: << parameters.run_logcat >> 176 | steps: 177 | - run: 178 | name: Logcat 179 | command: | 180 | adb logcat 181 | background: true 182 | - when: 183 | condition: << parameters.disable_animations >> 184 | steps: 185 | - disable_animations 186 | - << parameters.post_emulator_wait_steps >> 187 | -------------------------------------------------------------------------------- /src/commands/start_emulator_and_run_tests.yml: -------------------------------------------------------------------------------- 1 | description: | 2 | Creates an AVD, starts an emulator and runs tests. 3 | This is a wrapper command that wraps the 4 | create_avd, start_emulator and run_tests commands. 5 | parameters: 6 | avd_name: 7 | description: | 8 | The name of the AVD to create. 9 | You can pass environment variables, using the $ syntax e.g. "$AVD_NAME" 10 | type: string 11 | default: test 12 | system_image: 13 | description: | 14 | Name of system image e.g. "system-images;android-29;default;x86". 15 | It should match the name seen in the "sdkmanager --list" output. 16 | You can pass environment variables, using the $ syntax e.g. "$SYSTEM_IMAGE" 17 | type: string 18 | default: system-images;android-29;default;x86 19 | install_system_image: 20 | description: | 21 | Whether to first install the system image via sdkmanager 22 | type: boolean 23 | default: true 24 | additional_avd_args: 25 | description: | 26 | Additional args to be passed directly to the avd creation command. 27 | You can pass environment variables, using the $ syntax e.g. "$ADDITIONAL_ARGS" 28 | type: string 29 | default: "" 30 | gpu: 31 | description: | 32 | The value to use for the "-gpu" flag. 33 | If set to "", the emulator will be run without the -gpu flag. 34 | type: string 35 | default: "swiftshader_indirect" 36 | camera_front: 37 | description: | 38 | The value to use for the "-camera-front" flag. 39 | If set to "", the emulator will be run without the -camera-front flag. 40 | type: string 41 | default: "" 42 | camera_back: 43 | description: | 44 | The value to use for the "-camera-back" flag. 45 | If set to "", the emulator will be run without the -camera-back flag. 46 | type: string 47 | default: "" 48 | memory: 49 | description: | 50 | The value to use for the "-memory" flag. 51 | If set to -1, the emulator will be run without the -memory flag. 52 | type: integer 53 | default: -1 54 | no_window: 55 | description: | 56 | Whether to run the emulator with the -no-window flag 57 | type: boolean 58 | default: true 59 | no_audio: 60 | description: | 61 | Whether to run the emulator with the -noaudio flag 62 | type: boolean 63 | default: true 64 | no_boot_anim: 65 | description: | 66 | Whether to run the emulator with the -no-boot-anim flag 67 | type: boolean 68 | default: true 69 | no_snapshot: 70 | description: | 71 | Whether to run the emulator with the -no-snapshot flag 72 | type: boolean 73 | default: true 74 | delay_adb: 75 | description: | 76 | Whether to run the emulator with the -delay-adb flag 77 | type: boolean 78 | default: false 79 | verbose: 80 | description: | 81 | Whether to run the emulator with the -verbose flag 82 | type: boolean 83 | default: true 84 | additional_emulator_args: 85 | description: | 86 | Additional args to be passed directly to the emulator command 87 | type: string 88 | default: "" 89 | override_emulator_args: 90 | description: | 91 | If this is set to a non-blank value, the emulator command will be 92 | run with the -avd flag and the value of "override_args" (i.e. none of the defaults 93 | provided by the orb command will be used) 94 | type: string 95 | default: "" 96 | pre_emulator_wait_steps: 97 | description: | 98 | Steps to execute while before beginning to wait for the emulator to start up 99 | type: steps 100 | default: [] 101 | post_emulator_launch_assemble_command: 102 | description: | 103 | If this is set to a non-blank value, the configured command will be run 104 | after the emulator has been launched, and before commencing the 105 | wait for the emulator to finish starting up. 106 | type: string 107 | default: "./gradlew assembleDebugAndroidTest" 108 | restore_gradle_cache_post_emulator_launch: 109 | description: | 110 | Whether to restore the gradle cache after the emulator has been launched, 111 | and before commencing the wait for the emulator to finish starting up. 112 | type: boolean 113 | default: true 114 | restore_gradle_cache_prefix: 115 | description: | 116 | Cache prefix used if the "restore_gradle_cache_post_emulator_launch" parameter 117 | is set to true. 118 | type: string 119 | default: "v1" 120 | restore_gradle_cache_find_args: 121 | description: | 122 | Use this to customize how the find command is used to look for relevant 123 | file changes. 124 | type: string 125 | default: ". -name \"build.gradle*\" -o -name \"settings.gradle*\"" 126 | save_gradle_cache: 127 | description: | 128 | Whether to write to the gradle cache after the tests have run 129 | type: boolean 130 | default: true 131 | post_emulator_wait_steps: 132 | description: | 133 | Steps to execute after waiting for the emulator to start up 134 | type: steps 135 | default: [] 136 | wait_for_emulator: 137 | description: | 138 | Whether to wait for the emulator to start up 139 | type: boolean 140 | default: true 141 | run_logcat: 142 | description: | 143 | Whether to run with logcat in the background, after the emulator starts up 144 | type: boolean 145 | default: false 146 | disable_animations: 147 | description: | 148 | Whether to disable animations that may interfere with tests, after the emulator starts up 149 | type: boolean 150 | default: true 151 | pre_run_tests_steps: 152 | description: | 153 | Steps to run before the tests 154 | type: steps 155 | default: [] 156 | post_run_tests_steps: 157 | description: | 158 | Steps to run after the tests 159 | type: steps 160 | default: [] 161 | pre_test_command: 162 | description: | 163 | Command to run prior to runnning the test command 164 | You can pass environment variables, using the $ syntax e.g. "$PRE_TEST_COMMAND" 165 | type: string 166 | default: " " 167 | test_command: 168 | description: | 169 | Command to run in order to run the tests 170 | You can pass environment variables, using the $ syntax e.g. "$TEST_COMMAND" 171 | type: string 172 | default: "./gradlew connectedDebugAndroidTest" 173 | run_tests_working_directory: 174 | description: Working directory to run the tests in 175 | type: string 176 | default: "." 177 | max_tries: 178 | description: Max number of tries. To disable retries, set this to 1. 179 | type: integer 180 | default: 2 181 | retry_interval: 182 | description: Duration in seconds to wait before the next try 183 | type: integer 184 | default: 5 185 | no_output_timeout: 186 | description: | 187 | Use this to configure the no_output_timeout value of the test run 188 | type: string 189 | default: 10m 190 | kill_emulators: 191 | description: | 192 | Whether to kill the emulators after the tests complete 193 | type: boolean 194 | default: true 195 | pull_data: 196 | description: | 197 | Whether to pull data after running tests 198 | type: boolean 199 | default: false 200 | pull_data_path: 201 | description: | 202 | Emulator directory to pull data from 203 | type: string 204 | default: data 205 | pull_data_target: 206 | description: | 207 | Location to save pulled data 208 | type: string 209 | default: "." 210 | 211 | steps: 212 | - create_avd: 213 | avd_name: << parameters.avd_name >> 214 | system_image: <> 215 | install: << parameters.install_system_image >> 216 | additional_args: << parameters.additional_avd_args >> 217 | - start_emulator: 218 | avd_name: << parameters.avd_name >> 219 | gpu: << parameters.gpu >> 220 | camera_front: << parameters.camera_front >> 221 | camera_back: << parameters.camera_back >> 222 | memory: << parameters.memory >> 223 | no_window: << parameters.no_window >> 224 | no_audio: << parameters.no_audio >> 225 | no_boot_anim: << parameters.no_boot_anim >> 226 | no_snapshot: << parameters.no_snapshot >> 227 | delay_adb: << parameters.delay_adb >> 228 | verbose: << parameters.verbose >> 229 | additional_args: << parameters.additional_emulator_args >> 230 | override_args: << parameters.override_emulator_args >> 231 | wait_for_emulator: << parameters.wait_for_emulator >> 232 | pre_emulator_wait_steps: << parameters.pre_emulator_wait_steps >> 233 | post_emulator_launch_assemble_command: << parameters.post_emulator_launch_assemble_command >> 234 | restore_gradle_cache_post_emulator_launch: << parameters.restore_gradle_cache_post_emulator_launch >> 235 | restore_gradle_cache_prefix: << parameters.restore_gradle_cache_prefix >> 236 | restore_gradle_cache_find_args: << parameters.restore_gradle_cache_find_args >> 237 | post_emulator_wait_steps: << parameters.post_emulator_wait_steps >> 238 | run_logcat: << parameters.run_logcat >> 239 | disable_animations: << parameters.disable_animations >> 240 | - << parameters.pre_run_tests_steps >> 241 | - run_tests: 242 | working_directory: << parameters.run_tests_working_directory >> 243 | pre_test_command: << parameters.pre_test_command >> 244 | test_command: << parameters.test_command >> 245 | max_tries: << parameters.max_tries >> 246 | retry_interval: << parameters.retry_interval >> 247 | no_output_timeout: << parameters.no_output_timeout >> 248 | pull_data: << parameters.pull_data >> 249 | pull_data_path: << parameters.pull_data_path >> 250 | pull_data_target: << parameters.pull_data_target >> 251 | - << parameters.post_run_tests_steps >> 252 | - when: 253 | condition: << parameters.save_gradle_cache >> 254 | steps: 255 | - save_gradle_cache: 256 | cache_prefix: << parameters.restore_gradle_cache_prefix >> 257 | - when: 258 | condition: << parameters.kill_emulators >> 259 | steps: 260 | - kill_emulators 261 | -------------------------------------------------------------------------------- /src/commands/wait_for_emulator.yml: -------------------------------------------------------------------------------- 1 | description: | 2 | Wait for the emulator to start. 3 | Requires the "circle-android" script to be present in PATH. 4 | steps: 5 | - run: 6 | name: Wait for the emulator to start 7 | command: | 8 | circle-android wait-for-boot 9 | -------------------------------------------------------------------------------- /src/examples/granular_commands.yml: -------------------------------------------------------------------------------- 1 | description: | 2 | An example of using the more granular commands of the orb together, 3 | to achieve something similar to using the "start_emulator_and_run_tests" command 4 | or the "run_ui_tests" job. 5 | usage: 6 | version: 2.1 7 | orbs: 8 | android: circleci/android@3.0.0 9 | jobs: 10 | test: 11 | executor: 12 | name: android/android_machine 13 | tag: "default" 14 | resource_class: large 15 | steps: 16 | - checkout 17 | # Create an AVD named "myavd" 18 | - android/create_avd: 19 | avd_name: myavd 20 | system_image: system-images;android-31;default;x86_64 21 | install: true 22 | # By default, after starting up the emulator, a cache will be restored, 23 | # "./gradlew assembleDebugAndroidTest" will be run and then a script 24 | # will be run to wait for the emulator to start up. 25 | # Specify the "post_emulator_launch_assemble_command" command to override 26 | # the gradle command run, or set "wait_for_emulator" to false to disable 27 | # waiting for the emulator altogether. 28 | - android/start_emulator: 29 | avd_name: myavd 30 | no_window: true 31 | restore_gradle_cache_prefix: v1a 32 | # Runs "./gradlew connectedDebugAndroidTest" by default. 33 | # Specify the "test_command" parameter to customize the command run. 34 | - android/run_tests 35 | - android/save_gradle_cache: 36 | cache_prefix: v1a 37 | workflows: 38 | test: 39 | jobs: 40 | - test 41 | -------------------------------------------------------------------------------- /src/examples/override_machine_resource_class.yml: -------------------------------------------------------------------------------- 1 | description: | 2 | An example of overriding the android_machine executor's default resource class 3 | usage: 4 | version: 2.1 5 | orbs: 6 | android: circleci/android@3.0.0 7 | workflows: 8 | test: 9 | jobs: 10 | - android/run_ui_tests: 11 | executor: 12 | name: android/android_machine 13 | tag: "default" 14 | resource_class: xlarge 15 | -------------------------------------------------------------------------------- /src/examples/run_ui_tests_job.yml: -------------------------------------------------------------------------------- 1 | description: | 2 | A simple example of using the run_ui_tests job, 3 | using most of the default parameters. 4 | Parameters like the system_image and emulator options (e.g. "no_window") 5 | may need to be adjusted from the defaults, according to your project. 6 | usage: 7 | version: 2.1 8 | orbs: 9 | android: circleci/android@3.0.0 10 | workflows: 11 | test: 12 | jobs: 13 | - android/run_ui_tests: 14 | # Specify job "pre-steps" and "post-steps" if necessary 15 | # to execute custom steps before and afer any of the built-in steps 16 | system_image: "system-images;android-31;default;x86_64" 17 | executor: 18 | name: android/android_machine 19 | resource-class: large 20 | tag: 2024.01.1 21 | -------------------------------------------------------------------------------- /src/examples/start_emulator_and_run_tests.yml: -------------------------------------------------------------------------------- 1 | description: | 2 | A simple example of using the start_emulator_and_run_tests command 3 | in a job, using most of the default parameters. 4 | Parameters like the system_image and emulator options (e.g. "no_window") 5 | may need to be adjusted from the defaults, according to your project. 6 | usage: 7 | version: 2.1 8 | orbs: 9 | android: circleci/android@3.0.0 10 | jobs: 11 | test: 12 | executor: 13 | name: android/android_machine 14 | tag: "default" 15 | resource_class: large 16 | steps: 17 | - checkout 18 | # Creates an AVD and starts up the emulator using the AVD. 19 | # While the emulator is starting up, the gradle cache will 20 | # be restored and the Android app will be assembled. 21 | # When the emulator is ready, UI tests will be run. 22 | # After the tests are run, the gradle cache will be saved (if it 23 | # hasn't been saved before) 24 | - android/start_emulator_and_run_tests: 25 | system_image: system-images;android-31;default;x86_64 26 | # The cache prefix can be overridden 27 | # restore_gradle_cache_prefix: v1a 28 | # 29 | # The command to be run, while waiting for emulator startup, can be overridden 30 | # post_emulator_launch_assemble_command: ./gradlew assembleDebugAndroidTest 31 | # 32 | # The test command can be overridden 33 | # test_command: ./gradlew connectedDebugAndroidTest 34 | workflows: 35 | test: 36 | jobs: 37 | - test 38 | -------------------------------------------------------------------------------- /src/examples/test_matrix.yml: -------------------------------------------------------------------------------- 1 | description: | 2 | A simple example of using a test matrix to test on different 3 | emulators. 4 | usage: 5 | version: 2.1 6 | orbs: 7 | android: circleci/android@3.0.0 8 | workflows: 9 | test: 10 | jobs: 11 | - android/run_ui_tests: 12 | name: "ui-tests-<>" 13 | matrix: 14 | parameters: 15 | system_image: ["system-images;android-31;default;x86_64", "system-images;android-31;default;x86_64"] 16 | -------------------------------------------------------------------------------- /src/executors/android_docker.yml: -------------------------------------------------------------------------------- 1 | description: | 2 | Select a CircleCI convenience image to get building on Android. 3 | See https://circleci.com/developer/images/image/cimg/android#image-tags for a full list of 4 | the available images. 5 | 6 | parameters: 7 | tag: 8 | type: string 9 | description: | 10 | The Android image tag to use. 11 | Choose a tag from https://circleci.com/developer/images/image/cimg/android#image-tags. 12 | resource_class: 13 | description: Resource class used for the executor. 14 | type: enum 15 | default: medium 16 | enum: [small, medium, medium+, large, xlarge, 2xlarge, 2xlarge+] 17 | 18 | docker: 19 | - image: cimg/android:<< parameters.tag >> 20 | resource_class: << parameters.resource_class >> 21 | -------------------------------------------------------------------------------- /src/executors/android_machine.yml: -------------------------------------------------------------------------------- 1 | description: | 2 | This selects an Android machine image. 3 | CircleCI's Android machine images are recommended for Android emulator tests. 4 | 5 | parameters: 6 | tag: 7 | description: | 8 | Name of CircleCI Android machine image to use. 9 | Android machine tags can be found at https://circleci.com/developer/machine/image/android#image-tags 10 | type: string 11 | resource_class: 12 | description: | 13 | Resource class used for the executor. It is recommended 14 | to use large and above to avoid memory issues such as process 15 | crashes when running emulator tests. 16 | type: enum 17 | default: large 18 | enum: [medium, large, xlarge, 2xlarge] 19 | 20 | machine: 21 | image: android:<< parameters.tag >> 22 | resource_class: << parameters.resource_class >> 23 | -------------------------------------------------------------------------------- /src/jobs/build.yml: -------------------------------------------------------------------------------- 1 | description: > 2 | Start building an Android project on CircleCI 3 | 4 | parameters: 5 | executor: 6 | description: Executor for the job 7 | type: executor 8 | 9 | executor: << parameters.executor >> 10 | 11 | steps: 12 | - checkout 13 | - accept_licenses 14 | -------------------------------------------------------------------------------- /src/jobs/deploy_to_play_store.yml: -------------------------------------------------------------------------------- 1 | description: | 2 | Deploy an android app on CircleCI to the Google Play Store using Fastlane. For use with CirceCI Environment Variables. 3 | 4 | parameters: 5 | executor: 6 | description: Executor for the job 7 | type: executor 8 | base64_keystore: 9 | description: Your base64 keystore 10 | type: env_var_name 11 | default: BASE64_KEYSTORE 12 | keystore_location: 13 | description: The location of your decrypted keystore 14 | type: string 15 | default: '.' 16 | release_key_alias: 17 | description: Release key alias 18 | type: env_var_name 19 | default: RELEASE_KEY_ALIAS 20 | release_key_password: 21 | description: Password for your release key 22 | type: env_var_name 23 | default: RELEASE_KEY_PASSWORD 24 | release_keystore: 25 | description: Points to the location of your decrypted keystore 26 | type: string 27 | default: ./keystore 28 | release_store_password: 29 | description: Password for your keystore 30 | type: env_var_name 31 | default: RELEASE_STORE_PASSWORD 32 | keystore_properties_working_directory: 33 | description: Working directory to create keystore.properties in 34 | type: string 35 | default: '.' 36 | google_play_key: 37 | description: Your google play key 38 | type: env_var_name 39 | default: GOOGLE_PLAY_KEY 40 | lane_name: 41 | description: The name of the lane fastlane will execute 42 | type: string 43 | default: "deploy" 44 | fastlane_working_directory: 45 | description: Working directory to run fastlane commands in 46 | type: string 47 | default: '.' 48 | checkout: 49 | description: Whether to run the checkout step 50 | type: boolean 51 | default: true 52 | 53 | executor: << parameters.executor >> 54 | 55 | steps: 56 | - when: 57 | condition: << parameters.checkout >> 58 | steps: 59 | - checkout 60 | - decode_keystore: 61 | base64_keystore: << parameters.base64_keystore >> 62 | keystore_location: << parameters.keystore_location >> 63 | - create_keystore_properties: 64 | release_key_alias: << parameters.release_key_alias >> 65 | release_key_password: << parameters.release_key_password >> 66 | release_keystore: << parameters.release_keystore >> 67 | release_store_password: << parameters.release_store_password >> 68 | working_directory: << parameters.keystore_properties_working_directory >> 69 | - create_google_play_key: 70 | google_play_key: << parameters.google_play_key >> 71 | - fastlane_deploy: 72 | lane_name: << parameters.lane_name >> 73 | working_directory: << parameters.fastlane_working_directory >> 74 | -------------------------------------------------------------------------------- /src/jobs/run_ui_tests.yml: -------------------------------------------------------------------------------- 1 | description: | 2 | Creates an AVD, starts an emulator and runs Android UI tests. 3 | This is a job that wraps the "start_emulator_and_run_tests" command. 4 | parameters: 5 | pre_test_command: 6 | description: Command to run prior to runnning the test command 7 | type: string 8 | default: " " 9 | test_command: 10 | description: Command to run in order to run the tests 11 | type: string 12 | default: "./gradlew connectedDebugAndroidTest" 13 | system_image: 14 | description: | 15 | Name of system image e.g. "system-images;android-29;default;x86". 16 | It should match the name seen in the "sdkmanager --list" output. 17 | type: string 18 | default: system-images;android-29;default;x86 19 | pre_run_tests_steps: 20 | description: | 21 | Steps to run before the tests 22 | type: steps 23 | default: [] 24 | post_run_tests_steps: 25 | description: | 26 | Steps to run after the tests 27 | type: steps 28 | default: [] 29 | executor: 30 | description: Executor for the job 31 | type: executor 32 | checkout: 33 | description: Whether to run the checkout step 34 | type: boolean 35 | default: true 36 | avd_name: 37 | description: | 38 | The name of the AVD to create 39 | type: string 40 | default: test 41 | install_system_image: 42 | description: | 43 | Whether to first install the system image via sdkmanager 44 | type: boolean 45 | default: true 46 | additional_avd_args: 47 | description: | 48 | Additional args to be passed directly to the avd creation command 49 | type: string 50 | default: "" 51 | gpu: 52 | description: | 53 | The value to use for the "-gpu" flag. 54 | If set to "", the emulator will be run without the -gpu flag. 55 | type: string 56 | default: "swiftshader_indirect" 57 | camera_front: 58 | description: | 59 | The value to use for the "-camera-front" flag. 60 | If set to "", the emulator will be run without the -camera-front flag. 61 | type: string 62 | default: "" 63 | camera_back: 64 | description: | 65 | The value to use for the "-camera-back" flag. 66 | If set to "", the emulator will be run without the -camera-back flag. 67 | type: string 68 | default: "" 69 | memory: 70 | description: | 71 | The value to use for the "-memory" flag. 72 | If set to -1, the emulator will be run without the -memory flag. 73 | type: integer 74 | default: -1 75 | no_window: 76 | description: | 77 | Whether to run the emulator with the -no-window flag 78 | type: boolean 79 | default: true 80 | no_audio: 81 | description: | 82 | Whether to run the emulator with the -noaudio flag 83 | type: boolean 84 | default: true 85 | no_boot_anim: 86 | description: | 87 | Whether to run the emulator with the -no-boot-anim flag 88 | type: boolean 89 | default: true 90 | no_snapshot: 91 | description: | 92 | Whether to run the emulator with the -no-snapshot flag 93 | type: boolean 94 | default: true 95 | delay_adb: 96 | description: | 97 | Whether to run the emulator with the -delay-adb flag 98 | type: boolean 99 | default: false 100 | verbose: 101 | description: | 102 | Whether to run the emulator with the -verbose flag 103 | type: boolean 104 | default: true 105 | additional_emulator_args: 106 | description: | 107 | Additional args to be passed directly to the emulator command 108 | type: string 109 | default: "" 110 | override_emulator_args: 111 | description: | 112 | If this is set to a non-blank value, the emulator command will be 113 | run with the -avd flag and the value of "override_args" (i.e. none of the defaults 114 | provided by the orb command will be used) 115 | type: string 116 | default: "" 117 | pre_emulator_wait_steps: 118 | description: | 119 | Steps to execute while before beginning to wait for the emulator to start up 120 | type: steps 121 | default: [] 122 | post_emulator_launch_assemble_command: 123 | description: | 124 | If this is set to a non-blank value, the configured command will be run 125 | after the emulator has been launched, and before commencing the 126 | wait for the emulator to finish starting up. 127 | type: string 128 | default: "./gradlew assembleDebugAndroidTest" 129 | restore_gradle_cache_post_emulator_launch: 130 | description: | 131 | Whether to restore the gradle cache after the emulator has been launched, 132 | and before commencing the wait for the emulator to finish starting up. 133 | type: boolean 134 | default: true 135 | restore_gradle_cache_prefix: 136 | description: | 137 | Cache prefix used if the "restore_gradle_cache_post_emulator_launch" parameter 138 | is set to true. 139 | type: string 140 | default: "v1" 141 | restore_gradle_cache_find_args: 142 | description: | 143 | Use this to customize how the find command is used to look for relevant 144 | file changes. 145 | type: string 146 | default: ". -name \"build.gradle*\" -o -name \"settings.gradle*\"" 147 | save_gradle_cache: 148 | description: | 149 | Whether to write to the gradle cache after the tests have run 150 | type: boolean 151 | default: true 152 | post_emulator_wait_steps: 153 | description: | 154 | Steps to execute after waiting for the emulator to start up 155 | type: steps 156 | default: [] 157 | wait_for_emulator: 158 | description: | 159 | Whether to wait for the emulator to start up 160 | type: boolean 161 | default: true 162 | run_logcat: 163 | description: | 164 | Whether to run with logcat in the background, after the emulator starts up 165 | type: boolean 166 | default: false 167 | disable_animations: 168 | description: | 169 | Whether to disable animations that may interfere with tests, after the emulator starts up 170 | type: boolean 171 | default: true 172 | run_tests_working_directory: 173 | description: Working directory to run the tests in 174 | type: string 175 | default: "." 176 | max_tries: 177 | description: Max number of tries. To disable retries, set this to 1. 178 | type: integer 179 | default: 2 180 | retry_interval: 181 | description: Duration in seconds to wait before the next try 182 | type: integer 183 | default: 5 184 | no_output_timeout: 185 | description: | 186 | Use this to configure the no_output_timeout value of the test run 187 | type: string 188 | default: 10m 189 | kill_emulators: 190 | description: | 191 | Whether to kill the emulators after the tests complete 192 | type: boolean 193 | default: true 194 | pull_data: 195 | description: | 196 | Whether to pull data after running tests 197 | type: boolean 198 | default: false 199 | pull_data_path: 200 | description: | 201 | Emulator directory to pull data from 202 | type: string 203 | default: data 204 | pull_data_target: 205 | description: | 206 | Location to save pulled data 207 | type: string 208 | default: "." 209 | 210 | executor: << parameters.executor >> 211 | steps: 212 | - when: 213 | condition: << parameters.checkout >> 214 | steps: 215 | - checkout 216 | - start_emulator_and_run_tests: 217 | avd_name: << parameters.avd_name >> 218 | system_image: <> 219 | install_system_image: << parameters.install_system_image >> 220 | additional_avd_args: << parameters.additional_avd_args >> 221 | gpu: << parameters.gpu >> 222 | camera_front: << parameters.camera_front >> 223 | camera_back: << parameters.camera_back >> 224 | memory: << parameters.memory >> 225 | no_window: << parameters.no_window >> 226 | no_audio: << parameters.no_audio >> 227 | no_boot_anim: << parameters.no_boot_anim >> 228 | no_snapshot: << parameters.no_snapshot >> 229 | delay_adb: << parameters.delay_adb >> 230 | verbose: << parameters.verbose >> 231 | additional_emulator_args: << parameters.additional_emulator_args >> 232 | override_emulator_args: << parameters.override_emulator_args >> 233 | wait_for_emulator: << parameters.wait_for_emulator >> 234 | pre_emulator_wait_steps: << parameters.pre_emulator_wait_steps >> 235 | post_emulator_launch_assemble_command: << parameters.post_emulator_launch_assemble_command >> 236 | restore_gradle_cache_post_emulator_launch: << parameters.restore_gradle_cache_post_emulator_launch >> 237 | post_emulator_wait_steps: << parameters.post_emulator_wait_steps >> 238 | run_logcat: << parameters.run_logcat >> 239 | restore_gradle_cache_prefix: << parameters.restore_gradle_cache_prefix >> 240 | restore_gradle_cache_find_args: << parameters.restore_gradle_cache_find_args >> 241 | save_gradle_cache: << parameters.save_gradle_cache >> 242 | disable_animations: << parameters.disable_animations >> 243 | pre_run_tests_steps: << parameters.pre_run_tests_steps >> 244 | post_run_tests_steps: << parameters.post_run_tests_steps >> 245 | run_tests_working_directory: << parameters.run_tests_working_directory >> 246 | pre_test_command: << parameters.pre_test_command >> 247 | test_command: << parameters.test_command >> 248 | max_tries: << parameters.max_tries >> 249 | retry_interval: << parameters.retry_interval >> 250 | no_output_timeout: << parameters.no_output_timeout >> 251 | kill_emulators: << parameters.kill_emulators >> 252 | pull_data: << parameters.pull_data >> 253 | pull_data_path: << parameters.pull_data_path >> 254 | pull_data_target: << parameters.pull_data_target >> 255 | -------------------------------------------------------------------------------- /src/scripts/change_java_version.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | CURRENT_JAVA_VER="$(java -version 2>&1 | head -1 | cut -d'"' -f2 | sed '/^1\./s///' | cut -d'.' -f1)" 3 | CURRENT_JAVAC_VER="$(javac -version 2>&1 | head -1 | cut -f 2- -d ' ' | sed '/^1\./s///' | cut -d'.' -f1)" 4 | echo "Current Java Version: $CURRENT_JAVA_VER" 5 | echo "Current Java Compiler Version : $CURRENT_JAVAC_VER" 6 | if [ "$CURRENT_JAVA_VER" -ne "${PARAM_JAVA_VER}" ]; then 7 | if [ "${PARAM_JAVA_VER}" -eq 8 ] || [ "${PARAM_JAVA_VER}" -eq 17 ]; then 8 | if [ "${PARAM_JAVA_VER}" -eq 8 ]; then 9 | sudo update-alternatives --set java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java 10 | else 11 | sudo update-alternatives --set java /usr/lib/jvm/java-17-openjdk-amd64/bin/java 12 | fi 13 | sudo update-alternatives --set javac /usr/lib/jvm/java-"${PARAM_JAVA_VER}"-openjdk-amd64/bin/javac 14 | else 15 | sudo apt-get update 16 | sudo apt install openjdk-"${PARAM_JAVA_VER}"-jdk 17 | sudo update-alternatives --set javac /usr/lib/jvm/java-"${PARAM_JAVA_VER}"-openjdk-amd64/bin/javac 18 | sudo update-alternatives --set java /usr/lib/jvm/java-"${PARAM_JAVA_VER}"-openjdk-amd64/bin/java 19 | fi 20 | echo "export JAVA_HOME=/usr/lib/jvm/java-${PARAM_JAVA_VER}-openjdk-amd64" >> "$BASH_ENV" 21 | echo "export PATH=\$JAVA_HOME/bin:\$PATH" >> "$BASH_ENV" 22 | fi 23 | NEW_JAVA_VER="$(java -version 2>&1 | head -1 | cut -d'"' -f2 | sed '/^1\./s///' | cut -d'.' -f1)" 24 | NEW_JAVAC_VER="$(javac -version 2>&1 | head -1 | cut -f 2- -d ' ' | sed '/^1\./s///' | cut -d'.' -f1)" 25 | echo "New Java Version : $NEW_JAVA_VER" 26 | echo "New Java Compiler Version : $NEW_JAVAC_VER" 27 | -------------------------------------------------------------------------------- /src/scripts/change_malloc_implementation.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | sudo apt update 4 | 5 | if [[ ${PARAM_IMPLEMENTATION} == "jemalloc" ]]; then 6 | sudo apt install libjemalloc-dev 7 | echo "LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.2" | sudo tee -a /etc/environment 8 | else 9 | sudo apt install google-perftools 10 | echo "LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libtcmalloc.so.4" | sudo tee -a /etc/environment 11 | fi 12 | -------------------------------------------------------------------------------- /src/scripts/create_avd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | PARAM_AVD_NAME="$(echo "$PARAM_AVD_NAME" | circleci env subst "$PARAM_AVD_NAME")" 3 | PARAM_SYSTEM_IMAGE="$(echo "$PARAM_SYSTEM_IMAGE" | circleci env subst "$PARAM_SYSTEM_IMAGE")" 4 | PARAM_ADDITIONAL_ARGS="$(circleci env subst -- "$PARAM_ADDITIONAL_ARGS")" 5 | 6 | if [ "${PARAM_INSTALL}" == 1 ]; then 7 | sdkmanager "${PARAM_SYSTEM_IMAGE}" 8 | fi 9 | 10 | echo "no" | avdmanager --verbose create avd -n ${PARAM_AVD_NAME} -k ${PARAM_SYSTEM_IMAGE} ${PARAM_ADDITIONAL_ARGS} 11 | -------------------------------------------------------------------------------- /src/scripts/create_keystore_properties.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # RELEASE_KEY_ALIAS=$(eval echo "\$$PARAM_RELEASE_KEY_ALIAS") 4 | # RELEASE_KEY_PASSWORD=$(eval echo "\$$PARAM_RELEASE_KEY_PASSWORD") 5 | # RELEASE_STORE_PASSWORD=$(eval echo "\$$PARAM_RELEASE_STORE_PASSWORD") 6 | 7 | RELEASE_KEY_ALIAS="${!PARAM_RELEASE_KEY_ALIAS}" 8 | RELEASE_KEY_PASSWORD="${!PARAM_RELEASE_KEY_PASSWORD}" 9 | RELEASE_STORE_PASSWORD="${!PARAM_RELEASE_STORE_PASSWORD}" 10 | 11 | printf 'releaseKeyAlias=%s\nreleaseKeyPassword=%s\nreleaseKeyStore=%s\nreleaseStorePassword=%s' \ 12 | "$RELEASE_KEY_ALIAS" "$RELEASE_KEY_PASSWORD" "${PARAM_RELEASE_KEYSTORE}" "$RELEASE_STORE_PASSWORD" > keystore.properties -------------------------------------------------------------------------------- /src/scripts/decode_keystore.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | PARAM_BASE64_KEYSTORE=$(eval echo "\$$PARAM_BASE64_KEYSTORE") 4 | 5 | echo "$PARAM_BASE64_KEYSTORE" | base64 -di | tee keystore "${PARAM_KEYSTORE_LOCATION}" > /dev/null 6 | -------------------------------------------------------------------------------- /src/scripts/disable_animations.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | adb shell settings put global window_animation_scale 0.0 3 | adb shell settings put global transition_animation_scale 0.0 4 | adb shell settings put global animator_duration_scale 0.0 -------------------------------------------------------------------------------- /src/scripts/generate_cache_checksum.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "The following are the files used to generate the cache checksum:" 3 | eval find "${PARAM_FIND_ARGS}" 4 | eval find "${PARAM_FIND_ARGS}" | sort | xargs cat | 5 | shasum | awk '{print $1}' > /tmp/gradle_cache_seed 6 | -------------------------------------------------------------------------------- /src/scripts/install_ndk.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo y | sdkmanager "ndk;${PARAM_VER}" 3 | android_ndk_home="" 4 | if [[ -d "${HOME}/android-sdk/ndk/${PARAM_VER}" ]]; then 5 | android_ndk_home="$HOME/android-sdk/ndk/${PARAM_VER}" 6 | elif [[ -d "/opt/android/sdk/ndk/${PARAM_VER}" ]]; then 7 | android_ndk_home="/opt/android/sdk/ndk/${PARAM_VER}" 8 | else 9 | echo "Android NDK did not install successfully" 10 | exit 1 11 | fi 12 | echo "export ANDROID_NDK_HOME=$android_ndk_home" >> "$BASH_ENV" 13 | echo "Android NDK was installed at \"$android_ndk_home\"." -------------------------------------------------------------------------------- /src/scripts/kill_emulators.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # shellcheck disable=SC2154 3 | adb devices | grep emulator | cut -f1 | while read -r line; do adb -s $line emu kill; done -------------------------------------------------------------------------------- /src/scripts/run_tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | PARAM_PRE_TEST_COMMAND="$(echo "$PARAM_PRE_TEST_COMMAND" | circleci env subst "$PARAM_PRE_TEST_COMMAND")" 3 | PARAM_TEST_COMMAND="$(echo "$PARAM_TEST_COMMAND" | circleci env subst "$PARAM_TEST_COMMAND")" 4 | 5 | run_with_retry() { 6 | MAX_TRIES=${PARAM_MAX_TRIES} 7 | n=1 8 | until [ $n -gt $MAX_TRIES ]; do 9 | echo "Starting test attempt $n" 10 | eval "${PARAM_PRE_TEST_COMMAND}" 11 | eval "${PARAM_TEST_COMMAND}" && break 12 | n=$((n + 1)) 13 | sleep "${PARAM_RETRY_INTERVAL}" 14 | done 15 | if [ $n -gt $MAX_TRIES ]; then 16 | echo "Max tries reached (${PARAM_MAX_TRIES})" 17 | exit 1 18 | fi 19 | } 20 | run_with_retry 21 | -------------------------------------------------------------------------------- /src/scripts/start_emulator.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [ -n "${PARAM_OVERRIDE_ARGS}" ]; then 3 | echo "override-args parameter was supplied; orb defaults will be overridden" 4 | emulator -avd ${PARAM_AVD_NAME} ${PARAM_OVERRIDE_ARGS} 5 | else 6 | if [ "${PARAM_NO_WINDOW}" -eq 1 ]; then 7 | set -- "$@" -no-window 8 | fi 9 | if [ "${PARAM_NO_AUDIO}" -eq 1 ]; then 10 | set -- "$@" -no-audio 11 | fi 12 | if [ "${PARAM_NO_BOOT_ANIM}" -eq 1 ]; then 13 | set -- "$@" -no-boot-anim 14 | fi 15 | if [ "${PARAM_VERBOSE}" -eq 1 ]; then 16 | set -- "$@" -verbose 17 | fi 18 | if [ "${PARAM_NO_SNAPSHOT}" -eq 1 ]; then 19 | set -- "$@" -no-snapshot 20 | fi 21 | if [ "${PARAM_DELAY_ABD}" -eq 1 ]; then 22 | set -- "$@" -delay-adb 23 | fi 24 | if [ "${PARAM_MEMORY}" != "-1" ]; then 25 | set -- "$@" -memory ${PARAM_MEMORY} 26 | fi 27 | if [ -n "${PARAM_GPU}" ]; then 28 | set -- "$@" -gpu "${PARAM_GPU}" 29 | fi 30 | if [ -n "${PARAM_CAMERA_FRONT}" ]; then 31 | set -- "$@" -camera-front "${PARAM_CAMERA_FRONT}" 32 | fi 33 | if [ -n "${PARAM_CAMERA_BACK}" ]; then 34 | set -- "$@" -camera-back "${PARAM_CAMERA_BACK}" 35 | fi 36 | echo "Starting emulator with arguments $* ${PARAM_ADDITIONAL_ARGS}" 37 | emulator -avd ${PARAM_AVD_NAME} "$@" ${PARAM_ADDITIONAL_ARGS} 38 | fi 39 | --------------------------------------------------------------------------------