diff --git a/lib/sdk-installer.js b/lib/sdk-installer.js index 5291fd44b..8226798df 100644 --- a/lib/sdk-installer.js +++ b/lib/sdk-installer.js @@ -53,6 +53,9 @@ function installAndroidSdk(apiLevel, target, arch, channelId, emulatorBuild, ndk const isOnMac = process.platform === 'darwin'; const isArm = process.arch === 'arm64'; const cmdlineToolsPath = `${process.env.ANDROID_HOME}/cmdline-tools`; + if (fs.existsSync(cmdlineToolsPath)) { + yield io.rmRF(cmdlineToolsPath); + } if (!fs.existsSync(cmdlineToolsPath)) { console.log('Installing new cmdline-tools.'); const sdkUrl = isOnMac ? CMDLINE_TOOLS_URL_MAC : CMDLINE_TOOLS_URL_LINUX; @@ -61,7 +64,7 @@ function installAndroidSdk(apiLevel, target, arch, channelId, emulatorBuild, ndk yield io.mv(`${cmdlineToolsPath}/cmdline-tools`, `${cmdlineToolsPath}/latest`); } // add paths for commandline-tools and platform-tools - core.addPath(`${cmdlineToolsPath}/12.0:${cmdlineToolsPath}/12.0/bin:${process.env.ANDROID_HOME}/platform-tools`); + core.addPath(`${cmdlineToolsPath}/latest:${cmdlineToolsPath}/latest/bin:${process.env.ANDROID_HOME}/platform-tools`); // set standard AVD path core.exportVariable('ANDROID_AVD_HOME', `${process.env.HOME}/.android/avd`); // accept all Android SDK licenses diff --git a/src/sdk-installer.ts b/src/sdk-installer.ts index e7793bbf9..dfc5da6b9 100644 --- a/src/sdk-installer.ts +++ b/src/sdk-installer.ts @@ -20,6 +20,10 @@ export async function installAndroidSdk(apiLevel: string, target: string, arch: const isArm = process.arch === 'arm64'; const cmdlineToolsPath = `${process.env.ANDROID_HOME}/cmdline-tools`; + + if (fs.existsSync(cmdlineToolsPath)) { + await io.rmRF(cmdlineToolsPath); + } if (!fs.existsSync(cmdlineToolsPath)) { console.log('Installing new cmdline-tools.'); const sdkUrl = isOnMac ? CMDLINE_TOOLS_URL_MAC : CMDLINE_TOOLS_URL_LINUX; @@ -28,9 +32,6 @@ export async function installAndroidSdk(apiLevel: string, target: string, arch: await io.mv(`${cmdlineToolsPath}/cmdline-tools`, `${cmdlineToolsPath}/latest`); } - // print all folders under cmdline-tools - await exec.exec(`ls -l ${cmdlineToolsPath}`); - // add paths for commandline-tools and platform-tools core.addPath(`${cmdlineToolsPath}/latest:${cmdlineToolsPath}/latest/bin:${process.env.ANDROID_HOME}/platform-tools`);