Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save harshmandan/cd1e62c445982e48ae9218804ed4e1c9 to your computer and use it in GitHub Desktop.
Save harshmandan/cd1e62c445982e48ae9218804ed4e1c9 to your computer and use it in GitHub Desktop.
Follow these instruction to install Android SDK on a AWS EC2/DigitalOcean droplet or any other VPS instance where you do not have access to a GUI. Or if you just want the build tools/sdk without android studio.
#This is going to be our sdk installation directory
cd /home
#Install JDK first
sudo apt install openjdk-8-jdk
#Some utilities
sudo apt-get install unzip
sudo apt-get install git
#Install latest command line tools. Visit https://developer.android.com/studio/command-line for latest version. Use that link.
wget https://dl.google.com/android/repository/commandlinetools-linux-6514223_latest.zip
#Extract the downloaded zip
unzip commandlinetools-linux-6514223_latest.zip
# Set-up directory-structure for the sdk
mkdir android-sdk
mv tools android-sdk/
# Remove downloaded zip file
rm commandlinetools-*.zip
# Set-up the directory structure some more
cd android-sdk/
mkdir cmdline-tools
mv tools cmdline-tools/
# Export the path to enviroment
export ANDROID_HOME=/home/android-sdk
export PATH=$PATH:$ANDROID_HOME/cmdline-tools/platform-tools
export PATH=$PATH:$ANDROID_HOME/cmdline-tools/tools/bin
export PATH=$PATH:$ANDROID_HOME/cmdline-tools
# That's it! You have succesfully installed the Android SDK/Build tools via command line
# Follow along to set-up sdks so that you can start building
# You can use this command to see the list of available SDKs/NDKs/tools.
sdkmanager --list
# Run this command. The versions may change in the future. You'll also need to accept TnC. (Very important!)
sdkmanager "patcher;v4" "build-tools;28.0.3" "platforms;android-29" "platform-tools"
# Return back to home
cd /home
# Clone your favorite Android app's repository
git clone https://github.com/harshmandan/sample-android.git
cd sample-android/
# You may need to give execution permission to the gradlew file
sudo chmod +x gradlew
# Now you can start buidling! YAY!
./gradlew assemble
# Congratulations! You can now build you apps without any GUI/Android Studio.
# Bonus (for people who are new to *nix)
# When running long jobs on a VPS you may want to leave the terminal to do other things or just disconnect.
# You can use screen tool to do just that.
sudo apt-get install screen
# Screen let you create a virtual terminal or a secondary terminal where you can keep do stuff in background.
# Here's a very quick and solid guide to screen: https://www.youtube.com/watch?v=3txYaF_IVZQ
##### fin. ####################################
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment