Skip to content

Instantly share code, notes, and snippets.

@xinthink
Forked from PuKoren/codeship_android_build.sh
Created October 8, 2015 02:34
Show Gist options
  • Save xinthink/686b38fca26f455099f7 to your computer and use it in GitHub Desktop.
Save xinthink/686b38fca26f455099f7 to your computer and use it in GitHub Desktop.
Codeship Android build script
cd /tmp
pwd
#Download Android SDK from Google and unzip it
wget http://dl.google.com/android/android-sdk_r24.1.2-linux.tgz
tar zxvf android-sdk_r24.1.2-linux.tgz
rm android-sdk_r24.1.2-linux.tgz
#Set extracted SDK location to $PATH so we can use commands
export ANDROID_HOME="/tmp/android-sdk-linux"
export PATH="$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$PATH"
#Thanks to https://github.com/makinacorpus/android-archetypes/wiki/Getting-started:-Configure-your-environment for the command lines
#While loop is for auto-accept licence terms (press y every 1 sec)
#Install build tools
( sleep 1 && while [ 1 ]; do sleep 1; echo y; done ) | android update sdk --no-ui --all --filter tools,platform-tools,build-tools-21.1.2
#Now we want at least two SDK to test our build
#Install max SDK (API 22: should be your target SDK!)
( sleep 1 && while [ 1 ]; do sleep 1; echo y; done ) | android update sdk --no-ui --all --filter android-22,sys-img-armeabi-v7a-android-22,addon-google_apis-google-22
#Install min SDK (API 8) (Drop if you want to test only 1 SDK)
( sleep 1 && while [ 1 ]; do sleep 1; echo y; done ) | android update sdk --no-ui --all --filter android-8,sysimg-8,addon-google_apis-google-8
#Your extras here (Drop the ones you don't need it will speed up your build)
#( sleep 1 && while [ 1 ]; do sleep 1; echo y; done ) | android update sdk --no-ui --all --filter extra-android-m2repository,extra-android-support,extra-google-admob_ads_sdk,extra-google-analytics_sdk_v2,extra-google-google_play_services_froyo,extra-google-google_play_services,extra-google-m2repository,extra-google-play_apk_expansion,extra-google-play_billing,extra-google-play_licensing,extra-google-webdriver
#Go back to initial folder
cd -
touch local.properties
echo "sdk.dir=$ANDROID_HOME" >> local.properties
#Run build
./gradlew assembleDebug
#TEST SECTION, IGNORE IT IF YOU JUST WANT TO BUILD
#Create the AVD
#Use 'android list targets' to see targets ID, 1 should be API 8 and 2 API 22
mkdir avds
( sleep 1 && while [ 1 ]; do sleep 1; echo no; done ) | android create avd -t 1 -n API8 -c 512M -b armeabi
( sleep 1 && while [ 1 ]; do sleep 1; echo no; done ) | android create avd -t 2 -n API22 -c 512M -b armeabi
emulator -avd API8 -no-skin -no-audio -no-window &
adb wait-for-device #wait for device spawn
emulator -avd API22 -no-skin -no-audio -no-window &
adb wait-for-device #wait for second device spawn
./gradlew connectedCheck
./gradlew connectedAndroidTest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment