From c0431f28124524aced337e2be161655d6ebb1b11 Mon Sep 17 00:00:00 2001 From: Yang Date: Tue, 14 Apr 2020 23:57:49 +1000 Subject: [PATCH 1/5] Bump kotlin and AGP for test fixture project. --- test-fixture/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test-fixture/build.gradle b/test-fixture/build.gradle index 99387dbdf..d613bdc1a 100644 --- a/test-fixture/build.gradle +++ b/test-fixture/build.gradle @@ -1,13 +1,13 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.3.70' + ext.kotlin_version = '1.3.72' repositories { google() jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.6.0' + classpath 'com.android.tools.build:gradle:3.6.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong From 2513ea5ecf46dbe5a8a8d26e98b3e0aca9827e65 Mon Sep 17 00:00:00 2001 From: Yang Date: Sat, 25 Apr 2020 18:10:56 +1000 Subject: [PATCH 2/5] Add list of projects using android-emulator-runner. --- README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/README.md b/README.md index 9255cd556..1722ad7e1 100644 --- a/README.md +++ b/README.md @@ -105,3 +105,23 @@ jobs: Default `emulator-options`: `-no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim`. _Please note that if you are running on a Linux VM, `-no-accel` will be added to the `emulator-options` to make sure hardware acceleration is turned off._ + +## Who is using Android Emulator Runner? + +These are some of the open-source projects using (or used) **Android Emulator Runner**: + +- [coil-kt/coil](https://github.com/coil-kt/coil/blob/master/.github/workflows/) +- [cashapp/sqldelight](https://github.com/cashapp/sqldelight/blob/master/.github/workflows/) +- [square/workflow](https://github.com/square/workflow/blob/master/.github/workflows/) +- [square/retrofit](https://github.com/square/retrofit/blob/master/.github/workflows/) +- [natario1/CameraView](https://github.com/natario1/CameraView/tree/master/.github/workflows) +- [natario1/Transcoder](https://github.com/natario1/Transcoder/tree/master/.github/workflows) +- [chrisbanes/insetter](https://github.com/chrisbanes/insetter/tree/master/.github/workflows) +- [slaphq/keeper](https://github.com/slackhq/keeper/tree/master/.github/workflows) +- [android/compose-samples](https://github.com/android/compose-samples/blob/master/.github/workflows/ci.yaml) +- [ReactiveCircus/streamlined](https://github.com/ReactiveCircus/streamlined/tree/master/.github/workflows) +- [ReactiveCircus/FlowBinding](https://github.com/ReactiveCircus/FlowBinding) +- [vinaygaba/Learn-Jetpack-Compose-By-Example](https://github.com/vinaygaba/Learn-Jetpack-Compose-By-Example/) +- [ashishb/adb-enhanced](https://github.com/ashishb/adb-enhanced/tree/master/.github/workflows) + +If you are using **Android Emulator Runner** and want your project included in the list, please feel free to create an issue or open a pull request. From fdd35a3667d6ff1859effb2a16dcb20ab55d4f75 Mon Sep 17 00:00:00 2001 From: Yang Date: Sat, 25 Apr 2020 18:52:46 +1000 Subject: [PATCH 3/5] Fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1722ad7e1..77e85b83d 100644 --- a/README.md +++ b/README.md @@ -117,7 +117,7 @@ These are some of the open-source projects using (or used) **Android Emulator Ru - [natario1/CameraView](https://github.com/natario1/CameraView/tree/master/.github/workflows) - [natario1/Transcoder](https://github.com/natario1/Transcoder/tree/master/.github/workflows) - [chrisbanes/insetter](https://github.com/chrisbanes/insetter/tree/master/.github/workflows) -- [slaphq/keeper](https://github.com/slackhq/keeper/tree/master/.github/workflows) +- [slackhq/keeper](https://github.com/slackhq/keeper/tree/master/.github/workflows) - [android/compose-samples](https://github.com/android/compose-samples/blob/master/.github/workflows/ci.yaml) - [ReactiveCircus/streamlined](https://github.com/ReactiveCircus/streamlined/tree/master/.github/workflows) - [ReactiveCircus/FlowBinding](https://github.com/ReactiveCircus/FlowBinding) From f5435af41b35f094b8607b61e7f1e109d5b642cd Mon Sep 17 00:00:00 2001 From: Yang Date: Fri, 1 May 2020 20:02:07 +1000 Subject: [PATCH 4/5] Add support for specifying a custom name used for creating AVD. --- .github/workflows/workflow.yml | 1 + README.md | 3 +++ action.yml | 11 +++++++---- lib/emulator-manager.js | 8 ++++---- lib/main.js | 5 ++++- src/emulator-manager.ts | 8 ++++---- src/main.ts | 6 +++++- 7 files changed, 28 insertions(+), 14 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 5e6bb0c0a..f954a6ab1 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -52,6 +52,7 @@ jobs: target: default arch: x86 profile: Nexus 6 + avd-name: test emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -camera-back none disable-animations: true working-directory: ./test-fixture/ diff --git a/README.md b/README.md index 77e85b83d..529568a0f 100644 --- a/README.md +++ b/README.md @@ -88,12 +88,15 @@ jobs: ## Configurations +| | **Required** | **Default** | **Description** | +|----------------------|--------------|-------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | | **Required** | **Default** | **Description** | |----------------------|--------------|-------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `api-level` | Required | N/A | API level of the platform system image - e.g. 23 for Android Marshmallow, 29 for Android 10. **Minimum API level supported is 15**. | | `target` | Optional | `default` | Target of the system image - `default` or `google_apis`. | | `arch` | Optional | `x86` | CPU architecture of the system image - `x86` or `x86_64`. Note that `x86_64` image is only available for API 21+. | | `profile` | Optional | N/A | Hardware profile used for creating the AVD - e.g. `Nexus 6`. For a list of all profiles available, run `$ANDROID_HOME/tools/bin/avdmanager list` and refer to the results under "Available Android Virtual Devices". | +| `avd-name` | Optional | `test` | Custom AVD name used for creating the Android Virtual Device. | | `emulator-options` | Optional | See below | Command-line options used when launching the emulator (replacing all default options) - e.g. `-no-window -no-snapshot -camera-back emulated`. | | `disable-animations` | Optional | `true` | Whether to disable animations - `true` or `false`. | | `emulator-build` | Optional | N/A | Build number of a specific version of the emulator binary to use e.g. `6061023` for emulator v29.3.0.0. | diff --git a/action.yml b/action.yml index 6d8976d81..0d4f0ea75 100644 --- a/action.yml +++ b/action.yml @@ -15,17 +15,20 @@ inputs: description: 'CPU architecture of the system image - x86 or x86_64' default: 'x86' profile: - description: 'hardware profile used for creating the AVD - e.g. `Nexus 6`.' + description: 'hardware profile used for creating the AVD - e.g. `Nexus 6`' + avd-name: + description: 'custom AVD name used for creating the Android Virtual Device' + default: 'test' emulator-options: - description: 'command-line options used when launching the emulator - e.g. `-no-window -no-snapshot -camera-back emulated`.' + description: 'command-line options used when launching the emulator - e.g. `-no-window -no-snapshot -camera-back emulated`' default: '-no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim' disable-animations: description: 'whether to disable animations - true or false' default: 'true' emulator-build: - description: 'build number of a specific version of the emulator binary to use - e.g. `6061023` for emulator v29.3.0.0.' + description: 'build number of a specific version of the emulator binary to use - e.g. `6061023` for emulator v29.3.0.0' working-directory: - description: 'A custom working directory - e.g. `./android` if your root Gradle project is under the `./android` sub-directory within your repository.' + description: 'A custom working directory - e.g. `./android` if your root Gradle project is under the `./android` sub-directory within your repository' ndk: description: 'version of NDK to install - e.g. 21.0.6113669' cmake: diff --git a/lib/emulator-manager.js b/lib/emulator-manager.js index c8c788d11..ace29a7e6 100644 --- a/lib/emulator-manager.js +++ b/lib/emulator-manager.js @@ -20,16 +20,16 @@ const EMULATOR_BOOT_TIMEOUT_SECONDS = 600; /** * Creates and launches a new AVD instance with the specified configurations. */ -function launchEmulator(apiLevel, target, arch, profile, emulatorOptions, disableAnimations) { +function launchEmulator(apiLevel, target, arch, profile, avdName, emulatorOptions, disableAnimations) { return __awaiter(this, void 0, void 0, function* () { // create a new AVD if (profile.trim() !== '') { console.log(`Creating AVD with custom profile ${profile}`); - yield exec.exec(`avdmanager create avd --force -n test --abi "${target}/${arch}" --package "system-images;android-${apiLevel};${target};${arch}" --device "${profile}"`); + yield exec.exec(`avdmanager create avd --force -n "${avdName}" --abi "${target}/${arch}" --package "system-images;android-${apiLevel};${target};${arch}" --device "${profile}"`); } else { console.log(`Creating AVD without custom profile.`); - yield exec.exec(`sh -c \\"echo no | avdmanager create avd --force -n test --abi '${target}/${arch}' --package 'system-images;android-${apiLevel};${target};${arch}'"`); + yield exec.exec(`sh -c \\"echo no | avdmanager create avd --force -n "${avdName}" --abi '${target}/${arch}' --package 'system-images;android-${apiLevel};${target};${arch}'"`); } // start emulator console.log('Starting emulator.'); @@ -37,7 +37,7 @@ function launchEmulator(apiLevel, target, arch, profile, emulatorOptions, disabl if (process.platform === 'linux') { emulatorOptions += ' -accel off'; } - yield exec.exec(`sh -c \\"${process.env.ANDROID_HOME}/emulator/emulator -avd test ${emulatorOptions} &"`, [], { + yield exec.exec(`sh -c \\"${process.env.ANDROID_HOME}/emulator/emulator -avd "${avdName}" ${emulatorOptions} &"`, [], { listeners: { stderr: (data) => { if (data.toString().includes('invalid command-line parameter')) { diff --git a/lib/main.js b/lib/main.js index 367f7e437..f77d583ac 100644 --- a/lib/main.js +++ b/lib/main.js @@ -49,6 +49,9 @@ function run() { // Hardware profile used for creating the AVD const profile = core.getInput('profile'); console.log(`Hardware profile: ${profile}`); + // custom name used for creating the AVD + const avdName = core.getInput('avd-name'); + console.log(`AVD name: ${avdName}`); // emulator options const emulatorOptions = core.getInput('emulator-options').trim(); console.log(`emulator options: ${emulatorOptions}`); @@ -92,7 +95,7 @@ function run() { // install SDK yield sdk_installer_1.installAndroidSdk(apiLevel, target, arch, emulatorBuild, ndkVersion, cmakeVersion); // launch an emulator - yield emulator_manager_1.launchEmulator(apiLevel, target, arch, profile, emulatorOptions, disableAnimations); + yield emulator_manager_1.launchEmulator(apiLevel, target, arch, profile, avdName, emulatorOptions, disableAnimations); // execute the custom script try { // move to custom working directory if set diff --git a/src/emulator-manager.ts b/src/emulator-manager.ts index 03ebe5027..2c40c0104 100644 --- a/src/emulator-manager.ts +++ b/src/emulator-manager.ts @@ -5,14 +5,14 @@ const EMULATOR_BOOT_TIMEOUT_SECONDS = 600; /** * Creates and launches a new AVD instance with the specified configurations. */ -export async function launchEmulator(apiLevel: number, target: string, arch: string, profile: string, emulatorOptions: string, disableAnimations: boolean): Promise { +export async function launchEmulator(apiLevel: number, target: string, arch: string, profile: string, avdName: string, emulatorOptions: string, disableAnimations: boolean): Promise { // create a new AVD if (profile.trim() !== '') { console.log(`Creating AVD with custom profile ${profile}`); - await exec.exec(`avdmanager create avd --force -n test --abi "${target}/${arch}" --package "system-images;android-${apiLevel};${target};${arch}" --device "${profile}"`); + await exec.exec(`avdmanager create avd --force -n "${avdName}" --abi "${target}/${arch}" --package "system-images;android-${apiLevel};${target};${arch}" --device "${profile}"`); } else { console.log(`Creating AVD without custom profile.`); - await exec.exec(`sh -c \\"echo no | avdmanager create avd --force -n test --abi '${target}/${arch}' --package 'system-images;android-${apiLevel};${target};${arch}'"`); + await exec.exec(`sh -c \\"echo no | avdmanager create avd --force -n "${avdName}" --abi '${target}/${arch}' --package 'system-images;android-${apiLevel};${target};${arch}'"`); } // start emulator @@ -23,7 +23,7 @@ export async function launchEmulator(apiLevel: number, target: string, arch: str emulatorOptions += ' -accel off'; } - await exec.exec(`sh -c \\"${process.env.ANDROID_HOME}/emulator/emulator -avd test ${emulatorOptions} &"`, [], { + await exec.exec(`sh -c \\"${process.env.ANDROID_HOME}/emulator/emulator -avd "${avdName}" ${emulatorOptions} &"`, [], { listeners: { stderr: (data: Buffer) => { if (data.toString().includes('invalid command-line parameter')) { diff --git a/src/main.ts b/src/main.ts index 721f315f6..4bc73b29d 100644 --- a/src/main.ts +++ b/src/main.ts @@ -38,6 +38,10 @@ async function run() { const profile = core.getInput('profile'); console.log(`Hardware profile: ${profile}`); + // custom name used for creating the AVD + const avdName = core.getInput('avd-name'); + console.log(`AVD name: ${avdName}`); + // emulator options const emulatorOptions = core.getInput('emulator-options').trim(); console.log(`emulator options: ${emulatorOptions}`); @@ -89,7 +93,7 @@ async function run() { await installAndroidSdk(apiLevel, target, arch, emulatorBuild, ndkVersion, cmakeVersion); // launch an emulator - await launchEmulator(apiLevel, target, arch, profile, emulatorOptions, disableAnimations); + await launchEmulator(apiLevel, target, arch, profile, avdName, emulatorOptions, disableAnimations); // execute the custom script try { From 4df9257dba0a980a902e50ede07e089292417c5f Mon Sep 17 00:00:00 2001 From: Yang Date: Fri, 1 May 2020 20:18:07 +1000 Subject: [PATCH 5/5] Prepare for release 2.8.0. --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 789976aac..f28079cb9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## v2.8.0 + +* Added support for specifying a custom name used for creating the **AVD** - [#59](https://github.com/ReactiveCircus/android-emulator-runner/issues/59). + ## v2.7.0 * Added support for specifying versions of **NDK** and **CMake** to install.