From 49a3d042e9cc6a9f969d767b7e63b59d85a5cb83 Mon Sep 17 00:00:00 2001 From: Yang Chen Date: Wed, 1 Apr 2020 00:23:10 +1100 Subject: [PATCH] Fix sdk license issue with API 28+ system images on Linux. --- .github/workflows/workflow.yml | 4 +++- lib/emulator-manager.js | 4 ++-- lib/sdk-installer.js | 6 +++++- src/emulator-manager.ts | 4 ++-- src/sdk-installer.ts | 7 ++++++- 5 files changed, 18 insertions(+), 7 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 2a92fc8d..029f8092 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -14,12 +14,14 @@ jobs: strategy: matrix: os: [macos-latest, ubuntu-latest] - api-level: [16, 23, 29] + api-level: [16, 23, 28, 29] exclude: - os: ubuntu-latest api-level: 23 - os: ubuntu-latest api-level: 29 + - os: macos-latest + api-level: 28 steps: - name: checkout uses: actions/checkout@v2 diff --git a/lib/emulator-manager.js b/lib/emulator-manager.js index 160bd276..c8c788d1 100644 --- a/lib/emulator-manager.js +++ b/lib/emulator-manager.js @@ -16,7 +16,7 @@ var __importStar = (this && this.__importStar) || function (mod) { }; Object.defineProperty(exports, "__esModule", { value: true }); const exec = __importStar(require("@actions/exec")); -const EMULATOR_BOOT_TIMEOUT_SECONDS = 300; +const EMULATOR_BOOT_TIMEOUT_SECONDS = 600; /** * Creates and launches a new AVD instance with the specified configurations. */ @@ -99,7 +99,7 @@ function waitForDevice() { } } catch (error) { - console.log(error.message); + console.warn(error.message); } if (attempts < maxAttemps) { yield delay(retryInterval * 1000); diff --git a/lib/sdk-installer.js b/lib/sdk-installer.js index 1d7b00e1..e8fb3ab4 100644 --- a/lib/sdk-installer.js +++ b/lib/sdk-installer.js @@ -35,7 +35,11 @@ function installAndroidSdk(apiLevel, target, arch, emulatorBuild) { yield exec.exec(`sudo rm -f commandlinetools.zip`); // add paths for commandline-tools and platform-tools core.addPath(`${process.env.ANDROID_HOME}/cmdline-tools/tools:${process.env.ANDROID_HOME}/cmdline-tools/tools/bin:${process.env.ANDROID_HOME}/platform-tools`); - yield exec.exec(`sh -c \\"sudo chmod -R 777 ${process.env.ANDROID_HOME}"`); + // additional permission and license requirements for Linux + if (!isOnMac) { + yield exec.exec(`sh -c \\"sudo chmod -R 777 ${process.env.ANDROID_HOME}"`); + yield exec.exec(`sh -c \\"echo -e '\n84831b9409646a918e30573bab4c9c91346d8abd' > ${process.env.ANDROID_HOME}/licenses/android-sdk-preview-license"`); + } 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"`); if (emulatorBuild) { diff --git a/src/emulator-manager.ts b/src/emulator-manager.ts index 83f2c40f..03ebe502 100644 --- a/src/emulator-manager.ts +++ b/src/emulator-manager.ts @@ -1,6 +1,6 @@ import * as exec from '@actions/exec'; -const EMULATOR_BOOT_TIMEOUT_SECONDS = 300; +const EMULATOR_BOOT_TIMEOUT_SECONDS = 600; /** * Creates and launches a new AVD instance with the specified configurations. @@ -81,7 +81,7 @@ async function waitForDevice(): Promise { break; } } catch (error) { - console.log(error.message); + console.warn(error.message); } if (attempts < maxAttemps) { diff --git a/src/sdk-installer.ts b/src/sdk-installer.ts index 8d2f4bcb..fa7c69a5 100644 --- a/src/sdk-installer.ts +++ b/src/sdk-installer.ts @@ -20,7 +20,12 @@ export async function installAndroidSdk(apiLevel: number, target: string, arch: // add paths for commandline-tools and platform-tools core.addPath(`${process.env.ANDROID_HOME}/cmdline-tools/tools:${process.env.ANDROID_HOME}/cmdline-tools/tools/bin:${process.env.ANDROID_HOME}/platform-tools`); - await exec.exec(`sh -c \\"sudo chmod -R 777 ${process.env.ANDROID_HOME}"`); + + // additional permission and license requirements for Linux + if (!isOnMac) { + await exec.exec(`sh -c \\"sudo chmod -R 777 ${process.env.ANDROID_HOME}"`); + await exec.exec(`sh -c \\"echo -e '\n84831b9409646a918e30573bab4c9c91346d8abd' > ${process.env.ANDROID_HOME}/licenses/android-sdk-preview-license"`); + } console.log('Installing latest build tools, platform tools, and platform.');