Skip to content

Commit 4f4106d

Browse files
committed
Merge branch 'master' into release/v2
* master: Prepare for release 2.8.0. Add support for specifying a custom name used for creating AVD. Fix typo Add list of projects using android-emulator-runner. Bump kotlin and AGP for test fixture project.
2 parents 2f678a7 + 4df9257 commit 4f4106d

File tree

9 files changed

+54
-16
lines changed

9 files changed

+54
-16
lines changed

.github/workflows/workflow.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ jobs:
5252
target: default
5353
arch: x86
5454
profile: Nexus 6
55+
avd-name: test
5556
emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -camera-back none
5657
disable-animations: true
5758
working-directory: ./test-fixture/

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Change Log
22

3+
## v2.8.0
4+
5+
* Added support for specifying a custom name used for creating the **AVD** - [#59](https://github.com/ReactiveCircus/android-emulator-runner/issues/59).
6+
37
## v2.7.0
48

59
* Added support for specifying versions of **NDK** and **CMake** to install.

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,15 @@ jobs:
8888

8989
## Configurations
9090

91+
| | **Required** | **Default** | **Description** |
92+
|----------------------|--------------|-------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
9193
| | **Required** | **Default** | **Description** |
9294
|----------------------|--------------|-------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
9395
| `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**. |
9496
| `target` | Optional | `default` | Target of the system image - `default` or `google_apis`. |
9597
| `arch` | Optional | `x86` | CPU architecture of the system image - `x86` or `x86_64`. Note that `x86_64` image is only available for API 21+. |
9698
| `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". |
99+
| `avd-name` | Optional | `test` | Custom AVD name used for creating the Android Virtual Device. |
97100
| `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`. |
98101
| `disable-animations` | Optional | `true` | Whether to disable animations - `true` or `false`. |
99102
| `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. |
@@ -105,3 +108,23 @@ jobs:
105108
Default `emulator-options`: `-no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim`.
106109

107110
_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._
111+
112+
## Who is using Android Emulator Runner?
113+
114+
These are some of the open-source projects using (or used) **Android Emulator Runner**:
115+
116+
- [coil-kt/coil](https://github.com/coil-kt/coil/blob/master/.github/workflows/)
117+
- [cashapp/sqldelight](https://github.com/cashapp/sqldelight/blob/master/.github/workflows/)
118+
- [square/workflow](https://github.com/square/workflow/blob/master/.github/workflows/)
119+
- [square/retrofit](https://github.com/square/retrofit/blob/master/.github/workflows/)
120+
- [natario1/CameraView](https://github.com/natario1/CameraView/tree/master/.github/workflows)
121+
- [natario1/Transcoder](https://github.com/natario1/Transcoder/tree/master/.github/workflows)
122+
- [chrisbanes/insetter](https://github.com/chrisbanes/insetter/tree/master/.github/workflows)
123+
- [slackhq/keeper](https://github.com/slackhq/keeper/tree/master/.github/workflows)
124+
- [android/compose-samples](https://github.com/android/compose-samples/blob/master/.github/workflows/ci.yaml)
125+
- [ReactiveCircus/streamlined](https://github.com/ReactiveCircus/streamlined/tree/master/.github/workflows)
126+
- [ReactiveCircus/FlowBinding](https://github.com/ReactiveCircus/FlowBinding)
127+
- [vinaygaba/Learn-Jetpack-Compose-By-Example](https://github.com/vinaygaba/Learn-Jetpack-Compose-By-Example/)
128+
- [ashishb/adb-enhanced](https://github.com/ashishb/adb-enhanced/tree/master/.github/workflows)
129+
130+
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.

action.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,20 @@ inputs:
1515
description: 'CPU architecture of the system image - x86 or x86_64'
1616
default: 'x86'
1717
profile:
18-
description: 'hardware profile used for creating the AVD - e.g. `Nexus 6`.'
18+
description: 'hardware profile used for creating the AVD - e.g. `Nexus 6`'
19+
avd-name:
20+
description: 'custom AVD name used for creating the Android Virtual Device'
21+
default: 'test'
1922
emulator-options:
20-
description: 'command-line options used when launching the emulator - e.g. `-no-window -no-snapshot -camera-back emulated`.'
23+
description: 'command-line options used when launching the emulator - e.g. `-no-window -no-snapshot -camera-back emulated`'
2124
default: '-no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim'
2225
disable-animations:
2326
description: 'whether to disable animations - true or false'
2427
default: 'true'
2528
emulator-build:
26-
description: 'build number of a specific version of the emulator binary to use - e.g. `6061023` for emulator v29.3.0.0.'
29+
description: 'build number of a specific version of the emulator binary to use - e.g. `6061023` for emulator v29.3.0.0'
2730
working-directory:
28-
description: 'A custom working directory - e.g. `./android` if your root Gradle project is under the `./android` sub-directory within your repository.'
31+
description: 'A custom working directory - e.g. `./android` if your root Gradle project is under the `./android` sub-directory within your repository'
2932
ndk:
3033
description: 'version of NDK to install - e.g. 21.0.6113669'
3134
cmake:

lib/emulator-manager.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,24 @@ const EMULATOR_BOOT_TIMEOUT_SECONDS = 600;
2020
/**
2121
* Creates and launches a new AVD instance with the specified configurations.
2222
*/
23-
function launchEmulator(apiLevel, target, arch, profile, emulatorOptions, disableAnimations) {
23+
function launchEmulator(apiLevel, target, arch, profile, avdName, emulatorOptions, disableAnimations) {
2424
return __awaiter(this, void 0, void 0, function* () {
2525
// create a new AVD
2626
if (profile.trim() !== '') {
2727
console.log(`Creating AVD with custom profile ${profile}`);
28-
yield exec.exec(`avdmanager create avd --force -n test --abi "${target}/${arch}" --package "system-images;android-${apiLevel};${target};${arch}" --device "${profile}"`);
28+
yield exec.exec(`avdmanager create avd --force -n "${avdName}" --abi "${target}/${arch}" --package "system-images;android-${apiLevel};${target};${arch}" --device "${profile}"`);
2929
}
3030
else {
3131
console.log(`Creating AVD without custom profile.`);
32-
yield exec.exec(`sh -c \\"echo no | avdmanager create avd --force -n test --abi '${target}/${arch}' --package 'system-images;android-${apiLevel};${target};${arch}'"`);
32+
yield exec.exec(`sh -c \\"echo no | avdmanager create avd --force -n "${avdName}" --abi '${target}/${arch}' --package 'system-images;android-${apiLevel};${target};${arch}'"`);
3333
}
3434
// start emulator
3535
console.log('Starting emulator.');
3636
// turn off hardware acceleration on Linux
3737
if (process.platform === 'linux') {
3838
emulatorOptions += ' -accel off';
3939
}
40-
yield exec.exec(`sh -c \\"${process.env.ANDROID_HOME}/emulator/emulator -avd test ${emulatorOptions} &"`, [], {
40+
yield exec.exec(`sh -c \\"${process.env.ANDROID_HOME}/emulator/emulator -avd "${avdName}" ${emulatorOptions} &"`, [], {
4141
listeners: {
4242
stderr: (data) => {
4343
if (data.toString().includes('invalid command-line parameter')) {

lib/main.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ function run() {
4949
// Hardware profile used for creating the AVD
5050
const profile = core.getInput('profile');
5151
console.log(`Hardware profile: ${profile}`);
52+
// custom name used for creating the AVD
53+
const avdName = core.getInput('avd-name');
54+
console.log(`AVD name: ${avdName}`);
5255
// emulator options
5356
const emulatorOptions = core.getInput('emulator-options').trim();
5457
console.log(`emulator options: ${emulatorOptions}`);
@@ -92,7 +95,7 @@ function run() {
9295
// install SDK
9396
yield sdk_installer_1.installAndroidSdk(apiLevel, target, arch, emulatorBuild, ndkVersion, cmakeVersion);
9497
// launch an emulator
95-
yield emulator_manager_1.launchEmulator(apiLevel, target, arch, profile, emulatorOptions, disableAnimations);
98+
yield emulator_manager_1.launchEmulator(apiLevel, target, arch, profile, avdName, emulatorOptions, disableAnimations);
9699
// execute the custom script
97100
try {
98101
// move to custom working directory if set

src/emulator-manager.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ const EMULATOR_BOOT_TIMEOUT_SECONDS = 600;
55
/**
66
* Creates and launches a new AVD instance with the specified configurations.
77
*/
8-
export async function launchEmulator(apiLevel: number, target: string, arch: string, profile: string, emulatorOptions: string, disableAnimations: boolean): Promise<void> {
8+
export async function launchEmulator(apiLevel: number, target: string, arch: string, profile: string, avdName: string, emulatorOptions: string, disableAnimations: boolean): Promise<void> {
99
// create a new AVD
1010
if (profile.trim() !== '') {
1111
console.log(`Creating AVD with custom profile ${profile}`);
12-
await exec.exec(`avdmanager create avd --force -n test --abi "${target}/${arch}" --package "system-images;android-${apiLevel};${target};${arch}" --device "${profile}"`);
12+
await exec.exec(`avdmanager create avd --force -n "${avdName}" --abi "${target}/${arch}" --package "system-images;android-${apiLevel};${target};${arch}" --device "${profile}"`);
1313
} else {
1414
console.log(`Creating AVD without custom profile.`);
15-
await exec.exec(`sh -c \\"echo no | avdmanager create avd --force -n test --abi '${target}/${arch}' --package 'system-images;android-${apiLevel};${target};${arch}'"`);
15+
await exec.exec(`sh -c \\"echo no | avdmanager create avd --force -n "${avdName}" --abi '${target}/${arch}' --package 'system-images;android-${apiLevel};${target};${arch}'"`);
1616
}
1717

1818
// start emulator
@@ -23,7 +23,7 @@ export async function launchEmulator(apiLevel: number, target: string, arch: str
2323
emulatorOptions += ' -accel off';
2424
}
2525

26-
await exec.exec(`sh -c \\"${process.env.ANDROID_HOME}/emulator/emulator -avd test ${emulatorOptions} &"`, [], {
26+
await exec.exec(`sh -c \\"${process.env.ANDROID_HOME}/emulator/emulator -avd "${avdName}" ${emulatorOptions} &"`, [], {
2727
listeners: {
2828
stderr: (data: Buffer) => {
2929
if (data.toString().includes('invalid command-line parameter')) {

src/main.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ async function run() {
3838
const profile = core.getInput('profile');
3939
console.log(`Hardware profile: ${profile}`);
4040

41+
// custom name used for creating the AVD
42+
const avdName = core.getInput('avd-name');
43+
console.log(`AVD name: ${avdName}`);
44+
4145
// emulator options
4246
const emulatorOptions = core.getInput('emulator-options').trim();
4347
console.log(`emulator options: ${emulatorOptions}`);
@@ -89,7 +93,7 @@ async function run() {
8993
await installAndroidSdk(apiLevel, target, arch, emulatorBuild, ndkVersion, cmakeVersion);
9094

9195
// launch an emulator
92-
await launchEmulator(apiLevel, target, arch, profile, emulatorOptions, disableAnimations);
96+
await launchEmulator(apiLevel, target, arch, profile, avdName, emulatorOptions, disableAnimations);
9397

9498
// execute the custom script
9599
try {

test-fixture/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22

33
buildscript {
4-
ext.kotlin_version = '1.3.70'
4+
ext.kotlin_version = '1.3.72'
55
repositories {
66
google()
77
jcenter()
88
}
99
dependencies {
10-
classpath 'com.android.tools.build:gradle:3.6.0'
10+
classpath 'com.android.tools.build:gradle:3.6.2'
1111
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1212

1313
// NOTE: Do not place your application dependencies here; they belong

0 commit comments

Comments
 (0)