Skip to content

Instantly share code, notes, and snippets.

@pwicherski
Forked from nhtua/00.install-android-sdk.sh
Created December 13, 2023 18:01
Show Gist options
  • Select an option

  • Save pwicherski/7ad4bd64b1954c50f5877f7748d73c21 to your computer and use it in GitHub Desktop.

Select an option

Save pwicherski/7ad4bd64b1954c50f5877f7748d73c21 to your computer and use it in GitHub Desktop.
Run a Headless Android Device on Ubuntu server (no GUI)
#!/bin/bash -i
set -e #stop immediately if any error happens
# Install Open SDK
apt update
apt install openjdk-8-jdk -y
update-java-alternatives --set java-1.8.0-openjdk-amd64
java -version
# Install SDK Manager
# you can find this file at https://developer.android.com/studio/index.html#downloads - section command line only
cd ~ && wget https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip
ANDROID_HOME=/opt/androidsdk
mkdir -p $ANDROID_HOME
apt install unzip -y && unzip sdk-tools-linux-4333796.zip -d $ANDROID_HOME
echo "export ANDROID_HOME=$ANDROID_HOME" >> ~/.bashrc
echo 'export SDK=$ANDROID_HOME' >> ~/.bashrc
echo 'export PATH=$SDK/emulator:$SDK/tools:$SDK/tools/bin:$SDK/platform-tools:$PATH' >> ~/.bashrc
source ~/.bashrc
# Install Android Image version 28
yes | sdkmanager "platform-tools" "platforms;android-28" "emulator"
yes | sdkmanager "system-images;android-28;google_apis;x86_64"
emulator -version
#TODO add script to create Android Virtual Device (AVD) and start it
#You can find the ideas from https://docs.travis-ci.com/user/languages/android/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment