Forked from steveclarke/Install Android SDK CLI Ubuntu 20.04 WSL2.md
Last active
December 3, 2021 13:40
-
-
Save gryzinsky/09529ff11be8851b39e54fc3771bbad6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
# Install Android SDK CLI Ubuntu 20.04 WSL2 | |
# Functions | |
appendIfExists() { | |
if [ -f "$1" ]; then | |
cat >> "$1" | |
else | |
echo "File $1 does not exist. Discarding output." >&2 | |
return 1 | |
fi | |
} | |
include () { | |
if [ -f "$1" ]; then | |
source "$1" | |
fi | |
} | |
# Variables | |
export DEBIAN_FRONTEND=noninteractive | |
export ANDROID_HOME=$HOME/android/sdk | |
export CMD_TOOLS_VERSION="commandlinetools-linux-6200805_latest" | |
export BUILD_TOOLS_VERSION="28.0.3" | |
export ANDROID_VERSION="android-28" | |
# Install Open JDK 8 | |
sudo apt-get update && sudo apt-get install unzip libc6-dev-i386 lib32z1 openjdk-8-jdk-headless -y | |
# Install Android SDK | |
wget "https://dl.google.com/android/repository/$CMD_TOOLS_VERSION.zip" | |
mkdir -p "$HOME/android" | |
mkdir -p "$HOME/android/sdk" | |
unzip $CMD_TOOLS_VERSION -d "android/sdk/" | |
rm -rf "$CMD_TOOLS_VERSION.zip" | |
# Make sure emulator path comes before tools. Had trouble on Ubuntu with emulator from /tools being loaded | |
# instead of the one from /emulator | |
echo 'export PATH="$ANDROID_HOME/emulator:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools:$PATH"' | appendIfExists $HOME/.bashrc | |
echo 'export PATH="$ANDROID_HOME/emulator:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools:$PATH"' | appendIfExists $HOME/.zshrc | |
# Source profile | |
include "$HOME/.bashrc" | |
include "$HOME/.zshrc" | |
# Start sdkmanager | |
sdkmanager --sdk_root=${ANDROID_HOME} "tools" | |
# Update | |
sdkmanager --update | |
sdkmanager --list | |
sdkmanager "build-tools;$BUILD_TOOLS_VERSION" "platform-tools" "platforms;$ANDROID_VERSION" "tools" | |
sdkmanager --licenses | |
sudo apt install gradle -y |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment