mirror of
https://github.com/reactivecircus/android-emulator-runner.git
synced 2026-09-04 11:29:31 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5de26e4bd2 | |||
| 5e487dbdfe | |||
| 08852ad83b | |||
| 25bcfbab74 | |||
| ac874f3db5 | |||
| 0c3db9cd7a | |||
| eba1fbfb59 |
@@ -103,6 +103,7 @@ jobs:
|
|||||||
arch: x86
|
arch: x86
|
||||||
profile: Galaxy Nexus
|
profile: Galaxy Nexus
|
||||||
cores: 2
|
cores: 2
|
||||||
|
ram-size: 2048M
|
||||||
sdcard-path-or-size: 100M
|
sdcard-path-or-size: 100M
|
||||||
avd-name: test
|
avd-name: test
|
||||||
force-avd-creation: false
|
force-avd-creation: false
|
||||||
|
|||||||
@@ -1,5 +1,14 @@
|
|||||||
# Change Log
|
# Change Log
|
||||||
|
|
||||||
|
## v2.19.1
|
||||||
|
|
||||||
|
* Accept all Android SDL Licenses to fix `sdkmanager` installation. - [#172](https://github.com/ReactiveCircus/android-emulator-runner/pull/172) @marcuspridham.
|
||||||
|
|
||||||
|
## v2.19.0
|
||||||
|
|
||||||
|
* Add option to specify `ram-size` for the AVD. - [#165](https://github.com/ReactiveCircus/android-emulator-runner/pull/165).
|
||||||
|
|
||||||
|
|
||||||
## v2.18.1
|
## v2.18.1
|
||||||
|
|
||||||
* Added support for setting modern emulator build ids for `emulator-build`. Not all build ids are supported until we are able to figure out at which build id the download URL pattern changed. `7425822` (version 30.7.3) is currently the last known working build id.
|
* Added support for setting modern emulator build ids for `emulator-build`. Not all build ids are supported until we are able to figure out at which build id the download URL pattern changed. `7425822` (version 30.7.3) is currently the last known working build id.
|
||||||
|
|||||||
@@ -147,6 +147,7 @@ jobs:
|
|||||||
| `arch` | Optional | `x86` | CPU architecture of the system image - `x86`, `x86_64` or `arm64-v8a`. Note that `x86_64` image is only available for API 21+. `arm64-v8a` images require Android 4.2+ and are limited to fewer API levels (e.g. 30). |
|
| `arch` | Optional | `x86` | CPU architecture of the system image - `x86`, `x86_64` or `arm64-v8a`. Note that `x86_64` image is only available for API 21+. `arm64-v8a` images require Android 4.2+ and are limited to fewer API levels (e.g. 30). |
|
||||||
| `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). |
|
| `cores` | Optional | 2 | Number of cores to use for the emulator (`hw.cpu.ncore` in config.ini). |
|
||||||
|
| `ram-size` | Optional | N/A | Size of RAM to use for this AVD, in KB or MB, denoted with K or M. - e.g. `2048M` |
|
||||||
| `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. |
|
||||||
| `force-avd-creation` | Optional | `true` | Whether to force create the AVD by overwriting an existing AVD with the same name as `avd-name` - `true` or `false`. |
|
| `force-avd-creation` | Optional | `true` | Whether to force create the AVD by overwriting an existing AVD with the same name as `avd-name` - `true` or `false`. |
|
||||||
@@ -199,5 +200,6 @@ These are some of the open-source projects using (or used) **Android Emulator Ru
|
|||||||
- [wikimedia/apps-android-wikipedia](https://github.com/wikimedia/apps-android-wikipedia/blob/master/.github/workflows)
|
- [wikimedia/apps-android-wikipedia](https://github.com/wikimedia/apps-android-wikipedia/blob/master/.github/workflows)
|
||||||
- [google/android-fhir](https://github.com/google/android-fhir/tree/master/.github/workflows)
|
- [google/android-fhir](https://github.com/google/android-fhir/tree/master/.github/workflows)
|
||||||
- [google/accompanist](https://github.com/google/accompanist/blob/main/.github/workflows)
|
- [google/accompanist](https://github.com/google/accompanist/blob/main/.github/workflows)
|
||||||
|
- [dotanuki-labs/norris](https://github.com/dotanuki-labs/norris/blob/master/.github/workflows/main.yml)
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ inputs:
|
|||||||
cores:
|
cores:
|
||||||
description: 'the number of cores to use for the emulator'
|
description: 'the number of cores to use for the emulator'
|
||||||
default: 2
|
default: 2
|
||||||
|
ram-size:
|
||||||
|
description: 'size of RAM to use for this AVD, in KB or MB, denoted with K or M. - e.g. `2048M`'
|
||||||
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:
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ 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, cores, sdcardPathOrSize, avdName, forceAvdCreation, emulatorOptions, disableAnimations, disableSpellChecker, disableLinuxHardwareAcceleration) {
|
function launchEmulator(apiLevel, target, arch, profile, cores, ramSize, sdcardPathOrSize, avdName, forceAvdCreation, emulatorOptions, disableAnimations, disableSpellChecker, disableLinuxHardwareAcceleration) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
// create a new AVD if AVD directory does not already exist or forceAvdCreation is true
|
// create a new AVD if AVD directory does not already exist or forceAvdCreation is true
|
||||||
const avdPath = `${process.env.ANDROID_AVD_HOME}/${avdName}.avd`;
|
const avdPath = `${process.env.ANDROID_AVD_HOME}/${avdName}.avd`;
|
||||||
@@ -48,6 +48,9 @@ function launchEmulator(apiLevel, target, arch, profile, cores, sdcardPathOrSize
|
|||||||
if (cores) {
|
if (cores) {
|
||||||
yield exec.exec(`sh -c \\"printf 'hw.cpu.ncore=${cores}\n' >> ${process.env.ANDROID_AVD_HOME}/"${avdName}".avd"/config.ini`);
|
yield exec.exec(`sh -c \\"printf 'hw.cpu.ncore=${cores}\n' >> ${process.env.ANDROID_AVD_HOME}/"${avdName}".avd"/config.ini`);
|
||||||
}
|
}
|
||||||
|
if (ramSize) {
|
||||||
|
yield exec.exec(`sh -c \\"printf 'hw.ramSize=${ramSize}\n' >> ${process.env.ANDROID_AVD_HOME}/"${avdName}".avd"/config.ini`);
|
||||||
|
}
|
||||||
//turn off hardware acceleration on Linux
|
//turn off hardware acceleration on Linux
|
||||||
if (process.platform === 'linux' && disableLinuxHardwareAcceleration) {
|
if (process.platform === 'linux' && disableLinuxHardwareAcceleration) {
|
||||||
console.log('Disabling Linux hardware acceleration.');
|
console.log('Disabling Linux hardware acceleration.');
|
||||||
|
|||||||
+4
-1
@@ -66,6 +66,9 @@ function run() {
|
|||||||
// Number of cores to use for emulator
|
// Number of cores to use for emulator
|
||||||
const cores = core.getInput('cores');
|
const cores = core.getInput('cores');
|
||||||
console.log(`Cores: ${cores}`);
|
console.log(`Cores: ${cores}`);
|
||||||
|
// RAM to use for AVD
|
||||||
|
const ramSize = core.getInput('ram-size');
|
||||||
|
console.log(`RAM size: ${ramSize}`);
|
||||||
// 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}`);
|
||||||
@@ -130,7 +133,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, cores, sdcardPathOrSize, avdName, forceAvdCreation, emulatorOptions, disableAnimations, disableSpellchecker, disableLinuxHardwareAcceleration);
|
yield emulator_manager_1.launchEmulator(apiLevel, target, arch, profile, cores, ramSize, sdcardPathOrSize, avdName, forceAvdCreation, emulatorOptions, disableAnimations, disableSpellchecker, disableLinuxHardwareAcceleration);
|
||||||
// execute the custom script
|
// execute the custom script
|
||||||
try {
|
try {
|
||||||
// move to custom working directory if set
|
// move to custom working directory if set
|
||||||
|
|||||||
+2
-13
@@ -59,16 +59,8 @@ function installAndroidSdk(apiLevel, target, arch, emulatorBuild, ndkVersion, cm
|
|||||||
core.addPath(`${cmdlineToolsPath}/latest:${cmdlineToolsPath}/latest/bin:${process.env.ANDROID_SDK_ROOT}/platform-tools`);
|
core.addPath(`${cmdlineToolsPath}/latest:${cmdlineToolsPath}/latest/bin:${process.env.ANDROID_SDK_ROOT}/platform-tools`);
|
||||||
// set standard AVD path
|
// set standard AVD path
|
||||||
core.exportVariable('ANDROID_AVD_HOME', `${process.env.HOME}/.android/avd`);
|
core.exportVariable('ANDROID_AVD_HOME', `${process.env.HOME}/.android/avd`);
|
||||||
// additional permission and license requirements for Linux
|
// accept all Android SDK licenses
|
||||||
const sdkPreviewLicensePath = `${process.env.ANDROID_SDK_ROOT}/licenses/android-sdk-preview-license`;
|
yield exec.exec(`sh -c \\"yes | sdkmanager --licenses > /dev/null"`);
|
||||||
if (!isOnMac && !fs.existsSync(sdkPreviewLicensePath)) {
|
|
||||||
fs.writeFileSync(sdkPreviewLicensePath, '\n84831b9409646a918e30573bab4c9c91346d8abd');
|
|
||||||
}
|
|
||||||
// license required for API 30 and non-default API 28 system images
|
|
||||||
const sdkArmDbtLicensePath = `${process.env.ANDROID_SDK_ROOT}/licenses/android-sdk-arm-dbt-license`;
|
|
||||||
if (requiresArmDbtLicense(apiLevel, target) && !fs.existsSync(sdkArmDbtLicensePath)) {
|
|
||||||
fs.writeFileSync(sdkArmDbtLicensePath, '\n859f317696f67ef3d7f30a50a5560e7834b43903');
|
|
||||||
}
|
|
||||||
console.log('Installing latest build tools, platform tools, and platform.');
|
console.log('Installing latest build tools, platform tools, and platform.');
|
||||||
yield exec.exec(`sh -c \\"sdkmanager --install 'build-tools;${BUILD_TOOLS_VERSION}' platform-tools 'platforms;android-${apiLevel}' > /dev/null"`);
|
yield exec.exec(`sh -c \\"sdkmanager --install 'build-tools;${BUILD_TOOLS_VERSION}' platform-tools 'platforms;android-${apiLevel}' > /dev/null"`);
|
||||||
console.log('Installing latest emulator.');
|
console.log('Installing latest emulator.');
|
||||||
@@ -94,6 +86,3 @@ function installAndroidSdk(apiLevel, target, arch, emulatorBuild, ndkVersion, cm
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.installAndroidSdk = installAndroidSdk;
|
exports.installAndroidSdk = installAndroidSdk;
|
||||||
function requiresArmDbtLicense(apiLevel, target) {
|
|
||||||
return apiLevel === 30 || (apiLevel === 28 && target !== 'default');
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ export async function launchEmulator(
|
|||||||
arch: string,
|
arch: string,
|
||||||
profile: string,
|
profile: string,
|
||||||
cores: string,
|
cores: string,
|
||||||
|
ramSize: string,
|
||||||
sdcardPathOrSize: string,
|
sdcardPathOrSize: string,
|
||||||
avdName: string,
|
avdName: string,
|
||||||
forceAvdCreation: boolean,
|
forceAvdCreation: boolean,
|
||||||
@@ -35,6 +36,10 @@ export async function launchEmulator(
|
|||||||
await exec.exec(`sh -c \\"printf 'hw.cpu.ncore=${cores}\n' >> ${process.env.ANDROID_AVD_HOME}/"${avdName}".avd"/config.ini`);
|
await exec.exec(`sh -c \\"printf 'hw.cpu.ncore=${cores}\n' >> ${process.env.ANDROID_AVD_HOME}/"${avdName}".avd"/config.ini`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ramSize) {
|
||||||
|
await exec.exec(`sh -c \\"printf 'hw.ramSize=${ramSize}\n' >> ${process.env.ANDROID_AVD_HOME}/"${avdName}".avd"/config.ini`);
|
||||||
|
}
|
||||||
|
|
||||||
//turn off hardware acceleration on Linux
|
//turn off hardware acceleration on Linux
|
||||||
if (process.platform === 'linux' && disableLinuxHardwareAcceleration) {
|
if (process.platform === 'linux' && disableLinuxHardwareAcceleration) {
|
||||||
console.log('Disabling Linux hardware acceleration.');
|
console.log('Disabling Linux hardware acceleration.');
|
||||||
|
|||||||
@@ -52,6 +52,10 @@ async function run() {
|
|||||||
const cores = core.getInput('cores');
|
const cores = core.getInput('cores');
|
||||||
console.log(`Cores: ${cores}`);
|
console.log(`Cores: ${cores}`);
|
||||||
|
|
||||||
|
// RAM to use for AVD
|
||||||
|
const ramSize = core.getInput('ram-size');
|
||||||
|
console.log(`RAM size: ${ramSize}`);
|
||||||
|
|
||||||
// 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}`);
|
||||||
@@ -135,6 +139,7 @@ async function run() {
|
|||||||
arch,
|
arch,
|
||||||
profile,
|
profile,
|
||||||
cores,
|
cores,
|
||||||
|
ramSize,
|
||||||
sdcardPathOrSize,
|
sdcardPathOrSize,
|
||||||
avdName,
|
avdName,
|
||||||
forceAvdCreation,
|
forceAvdCreation,
|
||||||
|
|||||||
+2
-15
@@ -34,17 +34,8 @@ export async function installAndroidSdk(apiLevel: number, target: string, arch:
|
|||||||
// set standard AVD path
|
// set standard AVD path
|
||||||
core.exportVariable('ANDROID_AVD_HOME', `${process.env.HOME}/.android/avd`);
|
core.exportVariable('ANDROID_AVD_HOME', `${process.env.HOME}/.android/avd`);
|
||||||
|
|
||||||
// additional permission and license requirements for Linux
|
// accept all Android SDK licenses
|
||||||
const sdkPreviewLicensePath = `${process.env.ANDROID_SDK_ROOT}/licenses/android-sdk-preview-license`;
|
await exec.exec(`sh -c \\"yes | sdkmanager --licenses > /dev/null"`);
|
||||||
if (!isOnMac && !fs.existsSync(sdkPreviewLicensePath)) {
|
|
||||||
fs.writeFileSync(sdkPreviewLicensePath, '\n84831b9409646a918e30573bab4c9c91346d8abd');
|
|
||||||
}
|
|
||||||
|
|
||||||
// license required for API 30 and non-default API 28 system images
|
|
||||||
const sdkArmDbtLicensePath = `${process.env.ANDROID_SDK_ROOT}/licenses/android-sdk-arm-dbt-license`;
|
|
||||||
if (requiresArmDbtLicense(apiLevel, target) && !fs.existsSync(sdkArmDbtLicensePath)) {
|
|
||||||
fs.writeFileSync(sdkArmDbtLicensePath, '\n859f317696f67ef3d7f30a50a5560e7834b43903');
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log('Installing latest build tools, platform tools, and platform.');
|
console.log('Installing latest build tools, platform tools, and platform.');
|
||||||
|
|
||||||
@@ -73,7 +64,3 @@ export async function installAndroidSdk(apiLevel: number, target: string, arch:
|
|||||||
await exec.exec(`sh -c \\"sdkmanager --install 'cmake;${cmakeVersion}' > /dev/null"`);
|
await exec.exec(`sh -c \\"sdkmanager --install 'cmake;${cmakeVersion}' > /dev/null"`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function requiresArmDbtLicense(apiLevel: number, target: string): boolean {
|
|
||||||
return apiLevel === 30 || (apiLevel === 28 && target !== 'default');
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user