diff --git a/lib/sdk-installer.js b/lib/sdk-installer.js index 781ec61a8..b6b680bbd 100644 --- a/lib/sdk-installer.js +++ b/lib/sdk-installer.js @@ -51,7 +51,7 @@ function installAndroidSdk(apiLevel, target, arch, channelId, emulatorBuild, ndk console.log(`::group::Install Android SDK`); const isOnMac = process.platform === 'darwin'; if (!isOnMac) { - yield exec.exec(`sh -c \\"sudo chown $USER:$USER ${process.env.ANDROID_HOME} -R`); + yield exec.exec(`sh -c \\"sudo chown $(id -u):$(id -g) ${process.env.ANDROID_HOME} -R`); } const cmdlineToolsPath = `${process.env.ANDROID_HOME}/cmdline-tools`; if (!fs.existsSync(cmdlineToolsPath)) { @@ -81,6 +81,8 @@ function installAndroidSdk(apiLevel, target, arch, channelId, emulatorBuild, ndk } console.log('Installing system images.'); yield exec.exec(`sh -c \\"sdkmanager --install 'system-images;android-${apiLevel};${target};${arch}' --channel=${channelId} > /dev/null"`); + console.log('Installing platforms.'); + yield exec.exec(`sh -c \\"sdkmanager --install 'platforms;android-${apiLevel}' --channel=${channelId} > /dev/null"`); if (ndkVersion) { console.log(`Installing NDK ${ndkVersion}.`); yield exec.exec(`sh -c \\"sdkmanager --install 'ndk;${ndkVersion}' --channel=${channelId} > /dev/null"`); diff --git a/src/sdk-installer.ts b/src/sdk-installer.ts index 4383c6bf5..0fd7d69e3 100644 --- a/src/sdk-installer.ts +++ b/src/sdk-installer.ts @@ -18,7 +18,7 @@ export async function installAndroidSdk(apiLevel: string, target: string, arch: const isOnMac = process.platform === 'darwin'; if (!isOnMac) { - await exec.exec(`sh -c \\"sudo chown $USER:$USER ${process.env.ANDROID_HOME} -R`); + await exec.exec(`sh -c \\"sudo chown $(id -u):$(id -g) ${process.env.ANDROID_HOME} -R`); } const cmdlineToolsPath = `${process.env.ANDROID_HOME}/cmdline-tools`; @@ -57,6 +57,9 @@ export async function installAndroidSdk(apiLevel: string, target: string, arch: console.log('Installing system images.'); await exec.exec(`sh -c \\"sdkmanager --install 'system-images;android-${apiLevel};${target};${arch}' --channel=${channelId} > /dev/null"`); + console.log('Installing platforms.'); + await exec.exec(`sh -c \\"sdkmanager --install 'platforms;android-${apiLevel}' --channel=${channelId} > /dev/null"`); + if (ndkVersion) { console.log(`Installing NDK ${ndkVersion}.`); await exec.exec(`sh -c \\"sdkmanager --install 'ndk;${ndkVersion}' --channel=${channelId} > /dev/null"`);