#!/bin/bash

# Set env
export ANDROID_SDK_ROOT=/home/jenkins/android-sdk

# Install commandlinetools
rm -rf ${ANDROID_SDK_ROOT}
mkdir -p ${ANDROID_SDK_ROOT}
cd ${ANDROID_SDK_ROOT}
wget https://tools.mindspore.cn/tools/build/android-sdk/commandlinetools-linux-6858069_latest.zip
unzip commandlinetools-linux-6858069_latest.zip
rm -f commandlinetools-linux-6858069_latest.zip

# Generate latest
cd ${ANDROID_SDK_ROOT}/cmdline-tools/bin
./sdkmanager --sdk_root=${ANDROID_SDK_ROOT} "cmdline-tools;latest"

# Accept licenses
cd ${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin
yes|./sdkmanager --licenses

# Install
./sdkmanager "build-tools;30.0.1"
./sdkmanager "cmdline-tools;latest"
./sdkmanager "emulator"
./sdkmanager "patcher;v4"
./sdkmanager "platform-tools"
./sdkmanager "platforms;android-30"
./sdkmanager --list
