diff --git a/lib/emulator-manager.js b/lib/emulator-manager.js index 92207d33..6ae3305f 100644 --- a/lib/emulator-manager.js +++ b/lib/emulator-manager.js @@ -31,7 +31,7 @@ function launchEmulator(apiLevel, target, arch, profile, headless, disableAnimat } else { console.log(`Creating AVD without custom profile.`); - yield exec.exec(`bash -c \\"echo no | ${AVD_MANAGER_PATH} create avd --force -n test --abi '${target}/${arch}' --package 'system-images;android-${apiLevel};${target};${arch}'`); + yield exec.exec(`bash -c \\"echo no | ${AVD_MANAGER_PATH} create avd --force -n test --abi '${target}/${arch}' --package 'system-images;android-${apiLevel};${target};${arch}'"`); } // start emulator console.log('Starting emulator.'); diff --git a/lib/sdk-installer.js b/lib/sdk-installer.js index db55c27f..106742d9 100644 --- a/lib/sdk-installer.js +++ b/lib/sdk-installer.js @@ -16,33 +16,18 @@ var __importStar = (this && this.__importStar) || function (mod) { }; Object.defineProperty(exports, "__esModule", { value: true }); const exec = __importStar(require("@actions/exec")); -const tc = __importStar(require("@actions/tool-cache")); -const fs = __importStar(require("fs")); const BUILD_TOOLS_VERSION = '29.0.2'; -const SDK_URL = 'https://dl.google.com/android/repository/sdk-tools-darwin-4333796.zip'; /** - * Downloads and installs the Android SDK for the macOS platform, including SDK platform for the chosen API level, latest build tools, platform tools, Android Emulator, + * Installs & updates the Android SDK for the macOS platform, including SDK platform for the chosen API level, latest build tools, platform tools, Android Emulator, * and the system image for the chosen API level, CPU arch, and target. */ function installAndroidSdk(apiLevel, target, arch) { return __awaiter(this, void 0, void 0, function* () { - // download Android SDK if not already installed - if (fs.existsSync(`${process.env.ANDROID_HOME}/tools/bin/sdkmanager`)) { - console.log('Android SDK already installed.'); - } - else { - console.log('Downloading Android SDK.'); - const downloadedSdkPath = yield tc.downloadTool(SDK_URL); - yield tc.extractZip(downloadedSdkPath, process.env.ANDROID_HOME); - } - // install specific SDK tools - console.log('Installing build tools, platform tools, platform and system image.'); const sdkmangerPath = `${process.env.ANDROID_HOME}/tools/bin/sdkmanager`; - yield exec.exec(`echo "y" | ${sdkmangerPath} --licenses > /dev/null`); - yield exec.exec(`${sdkmangerPath} "build-tools;${BUILD_TOOLS_VERSION}"`); - yield exec.exec(`${sdkmangerPath} platform-tools "platforms;android-${apiLevel}"`); - yield exec.exec(`${sdkmangerPath} "system-images;android-${apiLevel};${target};${arch}"`); - yield exec.exec(`bash -c \\"${sdkmangerPath} --update > /dev/null"`); + console.log('Installing build tools, platform tools, and platform.'); + yield exec.exec(`bash -c \\"${sdkmangerPath} --install 'build-tools;${BUILD_TOOLS_VERSION}' platform-tools 'platforms;android-${apiLevel}' > /dev/null"`); + console.log('Installing system images.'); + yield exec.exec(`bash -c \\"${sdkmangerPath} --install 'system-images;android-${apiLevel};${target};${arch}' > /dev/null"`); }); } exports.installAndroidSdk = installAndroidSdk; diff --git a/src/emulator-manager.ts b/src/emulator-manager.ts index a4784867..2ea9f5a5 100644 --- a/src/emulator-manager.ts +++ b/src/emulator-manager.ts @@ -14,7 +14,7 @@ export async function launchEmulator(apiLevel: number, target: string, arch: str await exec.exec(`${AVD_MANAGER_PATH} create avd --force -n test --abi "${target}/${arch}" --package "system-images;android-${apiLevel};${target};${arch}" --device "${profile}"`); } else { console.log(`Creating AVD without custom profile.`); - await exec.exec(`bash -c \\"echo no | ${AVD_MANAGER_PATH} create avd --force -n test --abi '${target}/${arch}' --package 'system-images;android-${apiLevel};${target};${arch}'`); + await exec.exec(`bash -c \\"echo no | ${AVD_MANAGER_PATH} create avd --force -n test --abi '${target}/${arch}' --package 'system-images;android-${apiLevel};${target};${arch}'"`); } // start emulator diff --git a/src/sdk-installer.ts b/src/sdk-installer.ts index 980812a6..69ca5dc0 100644 --- a/src/sdk-installer.ts +++ b/src/sdk-installer.ts @@ -1,30 +1,15 @@ import * as exec from '@actions/exec'; -import * as tc from '@actions/tool-cache'; -import * as fs from 'fs'; const BUILD_TOOLS_VERSION = '29.0.2'; -const SDK_URL = 'https://dl.google.com/android/repository/sdk-tools-darwin-4333796.zip'; /** - * Downloads and installs the Android SDK for the macOS platform, including SDK platform for the chosen API level, latest build tools, platform tools, Android Emulator, + * Installs & updates the Android SDK for the macOS platform, including SDK platform for the chosen API level, latest build tools, platform tools, Android Emulator, * and the system image for the chosen API level, CPU arch, and target. */ export async function installAndroidSdk(apiLevel: number, target: string, arch: string): Promise { - // download Android SDK if not already installed - if (fs.existsSync(`${process.env.ANDROID_HOME}/tools/bin/sdkmanager`)) { - console.log('Android SDK already installed.'); - } else { - console.log('Downloading Android SDK.'); - const downloadedSdkPath = await tc.downloadTool(SDK_URL); - await tc.extractZip(downloadedSdkPath, process.env.ANDROID_HOME); - } - - // install specific SDK tools - console.log('Installing build tools, platform tools, platform and system image.'); const sdkmangerPath = `${process.env.ANDROID_HOME}/tools/bin/sdkmanager`; - await exec.exec(`echo "y" | ${sdkmangerPath} --licenses > /dev/null`); - await exec.exec(`${sdkmangerPath} "build-tools;${BUILD_TOOLS_VERSION}"`); - await exec.exec(`${sdkmangerPath} platform-tools "platforms;android-${apiLevel}"`); - await exec.exec(`${sdkmangerPath} "system-images;android-${apiLevel};${target};${arch}"`); - await exec.exec(`bash -c \\"${sdkmangerPath} --update > /dev/null"`); + console.log('Installing build tools, platform tools, and platform.'); + await exec.exec(`bash -c \\"${sdkmangerPath} --install 'build-tools;${BUILD_TOOLS_VERSION}' platform-tools 'platforms;android-${apiLevel}' > /dev/null"`); + console.log('Installing system images.'); + await exec.exec(`bash -c \\"${sdkmangerPath} --install 'system-images;android-${apiLevel};${target};${arch}' > /dev/null"`); }