Last active
May 9, 2024 14:22
-
-
Save groldo/25ee21cf9701307e5860b27057b8fa9a 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 bash | |
| # install android sdk and platform tools | |
| # chmod +x install_android_emulator.sh | |
| # run script with . ./install_android_emulator.sh | |
| WORKDIR="$(pwd)/android-sdk" | |
| install_java () { | |
| sudo apt update | |
| sudo apt install openjdk-8-jdk | |
| } | |
| install_platform_tools() { | |
| mkdir -p $WORKDIR | |
| pushd $WORKDIR | |
| wget https://dl.google.com/android/repository/platform-tools-latest-linux.zip | |
| unzip platform-tools-latest-linux.zip | |
| rm platform-tools-latest-linux.zip | |
| } | |
| install_cmdline_tools() { | |
| mkdir cmdline-tools | |
| pushd cmdline-tools | |
| wget https://dl.google.com/android/repository/commandlinetools-linux-8512546_latest.zip | |
| unzip commandlinetools-linux-8512546_latest.zip | |
| rm commandlinetools-linux-8512546_latest.zip | |
| mv cmdline-tools tools | |
| } | |
| update_path () { | |
| cat << EOF >> $HOME/.bashrc | |
| PATH=$WORKDIR/platform-tools:$WORKDIR/cmdline-tools/tools:$WORKDIR/cmdline-tools/tools/bin:\${PATH} | |
| ANDROID_HOME=$WORKDIR | |
| EOF | |
| source $HOME/.bashrc | |
| } | |
| if [ ! -d "$WORKDIR" ]; then | |
| install_java | |
| install_platform_tools | |
| install_cmdline_tools | |
| fi | |
| if ! command -v sdkmanager --version &>/dev/null; then | |
| update_path | |
| fi | |
| # :wq |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment