-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
install_android.sh
executable file
·39 lines (30 loc) · 1.3 KB
/
install_android.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/zsh
# fail if any commands fails
set -e
ANDROID_HOME="${HOME}/Library/Android/sdk"
if [ -f "${HOME}/.android/repositories.cfg" ]; then
echo "Config file already in place"
else
echo "Writting repositories.cfg"
if [[ ! -d "${HOME}/.android" ]]; then
mkdir "${HOME}/.android"
fi
touch "${HOME}/.android/repositories.cfg"
fi
if [ -d "${ANDROID_HOME}" ]; then
echo "Android sdk already installed"
else
ANDROID_TOOL_VERSION="commandlinetools-mac-8092744_latest"
mkdir -p "${ANDROID_HOME}"
TEMP_DIR="$(pwd)/.tmp"
if [ -d "${TEMP_DIR}" ]; then
rm -rf "${TEMP_DIR}"
fi
curl -L -X GET "https://dl.google.com/android/repository/${ANDROID_TOOL_VERSION}.zip" -o sdk.zip && unzip sdk.zip -d "${TEMP_DIR}" && rm sdk.zip
JAVA_HOME="$(/usr/libexec/java_home)" yes | $TEMP_DIR/cmdline-tools/bin/sdkmanager --licenses --sdk_root="${ANDROID_HOME}"
JAVA_HOME="$(/usr/libexec/java_home)" $TEMP_DIR/cmdline-tools/bin/sdkmanager --install "cmdline-tools;latest" --sdk_root="${ANDROID_HOME}"
rm -rf "$TEMP_DIR"
JAVA_HOME="$(/usr/libexec/java_home)" $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --install "emulator" "platform-tools" "extras;google;google_play_services"
fi
JAVA_HOME="$(/usr/libexec/java_home)" $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --update
echo "Installed Android on ${ANDROID_HOME}"