mirror of
https://github.com/reactivecircus/android-emulator-runner.git
synced 2026-09-03 19:09:32 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d2799957d6 | |||
| 838986e303 | |||
| 27a0759d85 | |||
| d85239a9fb |
@@ -71,6 +71,7 @@ jobs:
|
|||||||
target: ${{ matrix.target }}
|
target: ${{ matrix.target }}
|
||||||
arch: x86
|
arch: x86
|
||||||
profile: Nexus 6
|
profile: Nexus 6
|
||||||
|
cores: 2
|
||||||
sdcard-path-or-size: 100M
|
sdcard-path-or-size: 100M
|
||||||
avd-name: test
|
avd-name: test
|
||||||
emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -camera-back none
|
emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -camera-back none
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
# Change Log
|
# Change Log
|
||||||
|
|
||||||
|
## v2.15.0
|
||||||
|
|
||||||
|
* Added support for specifying the number of cores to use for the emulator - [#130](https://github.com/ReactiveCircus/android-emulator-runner/pull/130).
|
||||||
|
|
||||||
## v2.14.3
|
## v2.14.3
|
||||||
|
|
||||||
* Support `macos-11.0` (Big Sur) runner - [#124](https://github.com/ReactiveCircus/android-emulator-runner/pull/124).
|
* Support `macos-11.0` (Big Sur) runner - [#124](https://github.com/ReactiveCircus/android-emulator-runner/pull/124).
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ jobs:
|
|||||||
| `target` | Optional | `default` | Target of the system image - `default`, `google_apis` or `playstore`. |
|
| `target` | Optional | `default` | Target of the system image - `default`, `google_apis` or `playstore`. |
|
||||||
| `arch` | Optional | `x86` | CPU architecture of the system image - `x86` or `x86_64`. Note that `x86_64` image is only available for API 21+. |
|
| `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 `avdmanager list` and refer to the results under "Available Android Virtual Devices". |
|
| `profile` | Optional | N/A | Hardware profile used for creating the AVD - e.g. `Nexus 6`. For a list of all profiles available, run `avdmanager list` and refer to the results under "Available Android Virtual Devices". |
|
||||||
|
| `cores` | Optional | 2 | Number of cores to use for the emulator (`hw.cpu.ncore` in config.ini). |
|
||||||
| `sdcard-path-or-size` | Optional | N/A | Path to the SD card image for this AVD or the size of a new SD card image to create for this AVD, in KB or MB, denoted with K or M. - e.g. `path/to/sdcard`, or `1000M`. |
|
| `sdcard-path-or-size` | Optional | N/A | Path to the SD card image for this AVD or the size of a new SD card image to create for this AVD, in KB or MB, denoted with K or M. - e.g. `path/to/sdcard`, or `1000M`. |
|
||||||
| `avd-name` | Optional | `test` | Custom AVD name used for creating the Android Virtual Device. |
|
| `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`. |
|
| `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`. |
|
||||||
|
|||||||
@@ -16,6 +16,9 @@ inputs:
|
|||||||
default: 'x86'
|
default: 'x86'
|
||||||
profile:
|
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`'
|
||||||
|
cores:
|
||||||
|
description: 'the number of cores to use for the emulator'
|
||||||
|
default: 2
|
||||||
sdcard-path-or-size:
|
sdcard-path-or-size:
|
||||||
description: 'path to the SD card image for this AVD or the size of a new SD card image to create for this AVD, in KB or MB, denoted with K or M. - e.g. `path/to/sdcard`, or `1000M`'
|
description: 'path to the SD card image for this AVD or the size of a new SD card image to create for this AVD, in KB or MB, denoted with K or M. - e.g. `path/to/sdcard`, or `1000M`'
|
||||||
avd-name:
|
avd-name:
|
||||||
|
|||||||
@@ -34,13 +34,16 @@ const EMULATOR_BOOT_TIMEOUT_SECONDS = 600;
|
|||||||
/**
|
/**
|
||||||
* Creates and launches a new AVD instance with the specified configurations.
|
* Creates and launches a new AVD instance with the specified configurations.
|
||||||
*/
|
*/
|
||||||
function launchEmulator(apiLevel, target, arch, profile, sdcardPathOrSize, avdName, emulatorOptions, disableAnimations) {
|
function launchEmulator(apiLevel, target, arch, profile, cores, sdcardPathOrSize, avdName, emulatorOptions, disableAnimations) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
// create a new AVD
|
// create a new AVD
|
||||||
const profileOption = profile.trim() !== '' ? `--device '${profile}'` : '';
|
const profileOption = profile.trim() !== '' ? `--device '${profile}'` : '';
|
||||||
const sdcardPathOrSizeOption = sdcardPathOrSize.trim() !== '' ? `--sdcard '${sdcardPathOrSize}'` : '';
|
const sdcardPathOrSizeOption = sdcardPathOrSize.trim() !== '' ? `--sdcard '${sdcardPathOrSize}'` : '';
|
||||||
console.log(`Creating AVD.`);
|
console.log(`Creating AVD.`);
|
||||||
yield exec.exec(`sh -c \\"echo no | avdmanager create avd --force -n "${avdName}" --abi '${target}/${arch}' --package 'system-images;android-${apiLevel};${target};${arch}' ${profileOption} ${sdcardPathOrSizeOption}"`);
|
yield exec.exec(`sh -c \\"echo no | avdmanager create avd --force -n "${avdName}" --abi '${target}/${arch}' --package 'system-images;android-${apiLevel};${target};${arch}' ${profileOption} ${sdcardPathOrSizeOption}"`);
|
||||||
|
if (cores) {
|
||||||
|
yield exec.exec(`sh -c \\"printf 'hw.cpu.ncore=${cores}\n' >> ~/.android/avd/"${avdName}".avd"/config.ini`);
|
||||||
|
}
|
||||||
// start emulator
|
// start emulator
|
||||||
console.log('Starting emulator.');
|
console.log('Starting emulator.');
|
||||||
// turn off hardware acceleration on Linux
|
// turn off hardware acceleration on Linux
|
||||||
|
|||||||
+4
-1
@@ -63,6 +63,9 @@ function run() {
|
|||||||
// Hardware profile used for creating the AVD
|
// Hardware profile used for creating the AVD
|
||||||
const profile = core.getInput('profile');
|
const profile = core.getInput('profile');
|
||||||
console.log(`Hardware profile: ${profile}`);
|
console.log(`Hardware profile: ${profile}`);
|
||||||
|
// Number of cores to use for emulator
|
||||||
|
const cores = core.getInput('cores');
|
||||||
|
console.log(`Cores: ${cores}`);
|
||||||
// SD card path or size used for creating the AVD
|
// SD card path or size used for creating the AVD
|
||||||
const sdcardPathOrSize = core.getInput('sdcard-path-or-size');
|
const sdcardPathOrSize = core.getInput('sdcard-path-or-size');
|
||||||
console.log(`SD card path or size: ${sdcardPathOrSize}`);
|
console.log(`SD card path or size: ${sdcardPathOrSize}`);
|
||||||
@@ -112,7 +115,7 @@ function run() {
|
|||||||
// install SDK
|
// install SDK
|
||||||
yield sdk_installer_1.installAndroidSdk(apiLevel, target, arch, emulatorBuild, ndkVersion, cmakeVersion);
|
yield sdk_installer_1.installAndroidSdk(apiLevel, target, arch, emulatorBuild, ndkVersion, cmakeVersion);
|
||||||
// launch an emulator
|
// launch an emulator
|
||||||
yield emulator_manager_1.launchEmulator(apiLevel, target, arch, profile, sdcardPathOrSize, avdName, emulatorOptions, disableAnimations);
|
yield emulator_manager_1.launchEmulator(apiLevel, target, arch, profile, cores, sdcardPathOrSize, avdName, emulatorOptions, disableAnimations);
|
||||||
// execute the custom script
|
// execute the custom script
|
||||||
try {
|
try {
|
||||||
// move to custom working directory if set
|
// move to custom working directory if set
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ export async function launchEmulator(
|
|||||||
target: string,
|
target: string,
|
||||||
arch: string,
|
arch: string,
|
||||||
profile: string,
|
profile: string,
|
||||||
|
cores: string,
|
||||||
sdcardPathOrSize: string,
|
sdcardPathOrSize: string,
|
||||||
avdName: string,
|
avdName: string,
|
||||||
emulatorOptions: string,
|
emulatorOptions: string,
|
||||||
@@ -23,6 +24,10 @@ export async function launchEmulator(
|
|||||||
`sh -c \\"echo no | avdmanager create avd --force -n "${avdName}" --abi '${target}/${arch}' --package 'system-images;android-${apiLevel};${target};${arch}' ${profileOption} ${sdcardPathOrSizeOption}"`
|
`sh -c \\"echo no | avdmanager create avd --force -n "${avdName}" --abi '${target}/${arch}' --package 'system-images;android-${apiLevel};${target};${arch}' ${profileOption} ${sdcardPathOrSizeOption}"`
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (cores) {
|
||||||
|
await exec.exec(`sh -c \\"printf 'hw.cpu.ncore=${cores}\n' >> ~/.android/avd/"${avdName}".avd"/config.ini`);
|
||||||
|
}
|
||||||
|
|
||||||
// start emulator
|
// start emulator
|
||||||
console.log('Starting emulator.');
|
console.log('Starting emulator.');
|
||||||
|
|
||||||
|
|||||||
+5
-1
@@ -39,6 +39,10 @@ async function run() {
|
|||||||
const profile = core.getInput('profile');
|
const profile = core.getInput('profile');
|
||||||
console.log(`Hardware profile: ${profile}`);
|
console.log(`Hardware profile: ${profile}`);
|
||||||
|
|
||||||
|
// Number of cores to use for emulator
|
||||||
|
const cores = core.getInput('cores');
|
||||||
|
console.log(`Cores: ${cores}`);
|
||||||
|
|
||||||
// SD card path or size used for creating the AVD
|
// SD card path or size used for creating the AVD
|
||||||
const sdcardPathOrSize = core.getInput('sdcard-path-or-size');
|
const sdcardPathOrSize = core.getInput('sdcard-path-or-size');
|
||||||
console.log(`SD card path or size: ${sdcardPathOrSize}`);
|
console.log(`SD card path or size: ${sdcardPathOrSize}`);
|
||||||
@@ -98,7 +102,7 @@ async function run() {
|
|||||||
await installAndroidSdk(apiLevel, target, arch, emulatorBuild, ndkVersion, cmakeVersion);
|
await installAndroidSdk(apiLevel, target, arch, emulatorBuild, ndkVersion, cmakeVersion);
|
||||||
|
|
||||||
// launch an emulator
|
// launch an emulator
|
||||||
await launchEmulator(apiLevel, target, arch, profile, sdcardPathOrSize, avdName, emulatorOptions, disableAnimations);
|
await launchEmulator(apiLevel, target, arch, profile, cores, sdcardPathOrSize, avdName, emulatorOptions, disableAnimations);
|
||||||
|
|
||||||
// execute the custom script
|
// execute the custom script
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user