diff --git a/CHANGELOG.md b/CHANGELOG.md index e10d21f6f..2d8be9fa8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 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. + ## v2.18.0 * Add `force-avd-creation` which when set to `false` will skip avd creation if avd with same name exists. This enables AVD snapshot caching which can significantly reduce emulator startup time. See [README.md](https://github.com/ReactiveCircus/android-emulator-runner/blob/main/README.md#usage) for a sample workflow. - [#159](https://github.com/ReactiveCircus/android-emulator-runner/pull/159) diff --git a/lib/sdk-installer.js b/lib/sdk-installer.js index 099b2661f..21d5c3a00 100644 --- a/lib/sdk-installer.js +++ b/lib/sdk-installer.js @@ -71,17 +71,16 @@ function installAndroidSdk(apiLevel, target, arch, emulatorBuild, ndkVersion, cm } 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"`); + console.log('Installing latest emulator.'); + yield exec.exec(`sh -c \\"sdkmanager --install emulator > /dev/null"`); if (emulatorBuild) { console.log(`Installing emulator build ${emulatorBuild}.`); - yield exec.exec(`curl -fo emulator.zip https://dl.google.com/android/repository/emulator-${isOnMac ? 'darwin' : 'linux'}-${emulatorBuild}.zip`); - yield io.rmRF(`${process.env.ANDROID_SDK_ROOT}/emulator`); - yield exec.exec(`unzip -q emulator.zip -d ${process.env.ANDROID_SDK_ROOT}`); + // TODO find out the correct download URLs for all build ids + const downloadUrlSuffix = Number(emulatorBuild.charAt(0)) > 6 ? `_x64-${emulatorBuild}` : `-${emulatorBuild}`; + yield exec.exec(`curl -fo emulator.zip https://dl.google.com/android/repository/emulator-${isOnMac ? 'darwin' : 'linux'}${downloadUrlSuffix}.zip`); + yield exec.exec(`unzip -o -q emulator.zip -d ${process.env.ANDROID_SDK_ROOT}`); yield io.rmRF('emulator.zip'); } - else { - console.log('Installing latest emulator.'); - yield exec.exec(`sh -c \\"sdkmanager --install emulator > /dev/null"`); - } console.log('Installing system images.'); yield exec.exec(`sh -c \\"sdkmanager --install 'system-images;android-${apiLevel};${target};${arch}' > /dev/null"`); if (ndkVersion) { diff --git a/src/sdk-installer.ts b/src/sdk-installer.ts index 40738ba5b..b6f8111ad 100644 --- a/src/sdk-installer.ts +++ b/src/sdk-installer.ts @@ -49,15 +49,17 @@ export async function installAndroidSdk(apiLevel: number, target: string, arch: console.log('Installing latest build tools, platform tools, and platform.'); await exec.exec(`sh -c \\"sdkmanager --install 'build-tools;${BUILD_TOOLS_VERSION}' platform-tools 'platforms;android-${apiLevel}' > /dev/null"`); + + console.log('Installing latest emulator.'); + await exec.exec(`sh -c \\"sdkmanager --install emulator > /dev/null"`); + if (emulatorBuild) { console.log(`Installing emulator build ${emulatorBuild}.`); - await exec.exec(`curl -fo emulator.zip https://dl.google.com/android/repository/emulator-${isOnMac ? 'darwin' : 'linux'}-${emulatorBuild}.zip`); - await io.rmRF(`${process.env.ANDROID_SDK_ROOT}/emulator`); - await exec.exec(`unzip -q emulator.zip -d ${process.env.ANDROID_SDK_ROOT}`); + // TODO find out the correct download URLs for all build ids + const downloadUrlSuffix = Number(emulatorBuild.charAt(0)) > 6 ? `_x64-${emulatorBuild}` : `-${emulatorBuild}`; + await exec.exec(`curl -fo emulator.zip https://dl.google.com/android/repository/emulator-${isOnMac ? 'darwin' : 'linux'}${downloadUrlSuffix}.zip`); + await exec.exec(`unzip -o -q emulator.zip -d ${process.env.ANDROID_SDK_ROOT}`); await io.rmRF('emulator.zip'); - } else { - console.log('Installing latest emulator.'); - await exec.exec(`sh -c \\"sdkmanager --install emulator > /dev/null"`); } console.log('Installing system images.'); await exec.exec(`sh -c \\"sdkmanager --install 'system-images;android-${apiLevel};${target};${arch}' > /dev/null"`);