Skip to content

Instantly share code, notes, and snippets.

@reline
Last active January 14, 2020 21:19
Show Gist options
  • Save reline/9fe69456b40cb228197a83384ef46026 to your computer and use it in GitHub Desktop.
Save reline/9fe69456b40cb228197a83384ef46026 to your computer and use it in GitHub Desktop.
Ultimate Android build system dependency script (Ubuntu 14.04)
apt-get update
apt-get install -y software-properties-common
echo debconf shared/accepted-oracle-license-v1-1 select true | debconf-set-selections
echo debconf shared/accepted-oracle-license-v1-1 seen true | debconf-set-selections
add-apt-repository -y ppa:webupd8team/java
dpkg --add-architecture i386
apt-get update
apt-get install -y --force-yes apt-utils build-essential git unzip oracle-java8-installer python libreadline-dev curl bzip2 libssl-dev zlib1g-dev libc6:i386 libncurses5:i386 libstdc++6:i386 lib32z1 libbz2-1.0:i386
apt-get -fy install
git clone https://github.com/rbenv/rbenv.git $HOME/.rbenv
git clone https://github.com/rbenv/ruby-build.git $HOME/.rbenv/plugins/ruby-build
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash
rbenv install 2.4.2
rbenv global 2.4.2
gem install bundler
gem install fastlane -NV
wget https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip
unzip sdk-tools-linux-*.zip -d $HOME/android-sdk-linux
export PATH="$HOME/android-sdk-linux/tools:$PATH"
export PATH="$HOME/android-sdk-linux/tools/bin:$PATH"
yes | sdkmanager --licenses
sdkmanager "platform-tools" "tools" "emulator"
for i in `seq 26`; do sdkmanager "platforms;android-$i"; done
import subprocess
output = subprocess.check_output(['adb', 'devices'])
lines = output.splitlines()
lines.pop(0)
lines.pop()
if len(lines) != 0:
print(output)
print('Killing devices: ')
for line in lines:
device = line.split('\t')[0]
print(device)
print(subprocess.check_output(['adb', '-s', device, 'emu', 'kill']))
else:
print('No devices attached')
echo "Accepting SDK package licenses..."
yes | sdkmanager --licenses
echo "Creating emulator..."
sdkmanager "system-images;android-19;google_apis;x86"
echo no | avdmanager create avd --force --name test --package "system-images;android-19;google_apis;x86"
echo
echo "Created emulator"
Process.fork { `$(which emulator) -avd test -no-audio -no-window` }
./setup_emulator.sh
python kill_devices.py # just in case, kill all connected devices
ruby start_emulator.rb
adb wait-for-device
gradle test
gradle connectedAndroidTest
python kill_devices.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment