Last active
February 12, 2021 07:13
-
-
Save paulonteri/a37b0ead46981b87ad5fdb95d54f2ceb 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
#!/bin/bash -i | |
# using shebang with -i to enable interactive mode (auto load .bashrc) | |
set -e #stop immediately if any error happens | |
# Install Open SDK | |
sudo apt-get update | |
sudo apt-get install openjdk-8-jdk -y | |
sudo update-java-alternatives --set java-1.8.0-openjdk-amd64 | |
java -version | |
# create sdk folder | |
export ANDROID_HOME=~/opt/androidsdk | |
if [ -d "$ANDROID_HOME" ]; then sudo rm -Rf $ANDROID_HOME; fi | |
echo $ANDROID_HOME | |
mkdir -p $ANDROID_HOME | |
# 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 | |
sudo apt-get install unzip -y && unzip sdk-tools-linux-4333796.zip -d $ANDROID_HOME | |
rm sdk-tools-linux-4333796.zip | |
# Install gradle | |
sudo apt-get install gradle | |
# Install avd | |
yes | $ANDROID_HOME/tools/bin/sdkmanager "platform-tools" "system-images;android-25;google_apis;armeabi-v7a" "emulator" | |
yes | $ANDROID_HOME/tools/bin/sdkmanager "system-images;android-25;google_apis;armeabi-v7a" | |
# install all sdk packages | |
# $ANDROID_HOME/android update sdk --no-ui | |
### | |
### | |
### | |
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 | |
emulator -version | |
### | |
### | |
### | |
# stop emulators | |
adb devices | grep emulator | cut -f1 | while read line; do adb -s $line emu kill; done | |
# download script thalt helps in telling if emulator has started | |
# https://raw.githubusercontent.com/travis-ci/travis-cookbooks/master/community-cookbooks/android-sdk/files/default/android-wait-for-emulator | |
wget --quiet --output-document=android-wait-for-emulator https://raw.githubusercontent.com/travis-ci/travis-cookbooks/0f497eb71291b52a703143c5cd63a217c8766dc9/community-cookbooks/android-sdk/files/default/android-wait-for-emulator | |
chmod +x android-wait-for-emulator | |
# create virtual device, default using (API Level 25) | |
echo no | avdmanager create avd -f -n avd28 -k "system-images;android-25;google_apis;armeabi-v7a" | |
# start the emulator | |
emulator -avd avd28 -no-audio -no-window -no-boot-anim & ./android-wait-for-emulator | |
# show connected virtual device(s) | |
adb devices | |
echo "INSTALL ANDROID SDK DONE!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment