Skip to content

Instantly share code, notes, and snippets.

@calvinchengx
Last active May 11, 2022 23:24
Show Gist options
  • Save calvinchengx/5cf8c58853af76c0ffd2623f9be763eb to your computer and use it in GitHub Desktop.
Save calvinchengx/5cf8c58853af76c0ffd2623f9be763eb to your computer and use it in GitHub Desktop.
Install android sdk, ndk in headless ubuntu
#!/bin/bash
rm commandlinetools-*.zip
sudo apt-get install libc6-dev-i386 lib32z1 openjdk-8-jdk build-essential --yes
wget https://dl.google.com/android/repository/commandlinetools-linux-8092744_latest.zip
unzip commandlinetools-linux-8092744_latest.zip
export ANDROID_HOME=$HOME/Android
export ANDROID_SDK_ROOT=$ANDROID_HOME/sdk
mkdir -p $ANDROID_SDK_ROOT
mkdir -p $ANDROID_SDK_ROOT/cmdline-tools
cp -rf cmdline-tools $ANDROID_SDK_ROOT/cmdline-tools/latest
rm -rf cmdline-tools
cat << EOF >> $HOME/.bashrc
export ANDROID_HOME=$HOME/Android
export ANDROID_SDK_ROOT=\$ANDROID_HOME/sdk
export PATH=\$PATH:\$ANDROID_SDK_ROOT/cmdline-tools/latest/bin
EOF
source $HOME/.bashrc
echo "ANDROID_HOME: $ANDROID_HOME"
echo "ANDROID_SDK_ROOT: $ANDROID_SDK_ROOT"
echo "PATH: $PATH"
yes | sdkmanager --licenses
sdkmanager "platforms;android-21" "build-tools;21.1.2" "ndk-bundle"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment