I need to integrate a continuous integration system in my Android project, I have seen that CodeShip is a good alternative so I have created and configured a project to compile my Android application using the following script:
# Install java 8
jdk_switcher home oraclejdk8
jdk_switcher use oraclejdk8
export JAVA8_HOME=/usr/lib/jvm/java-8-oracle
export BUILD_TOOLS_VERSION=23.0.3
export ANDROID_SDK=24
export ANDROID_SDK_REV=24.4.1
#
# Install android sdk
export SDK_TAR=android-sdk_r$ANDROID_SDK_REV-linux
wget "http://dl.google.com/android/$SDK_TAR.tgz"
tar xvzf "$SDK_TAR.tgz"
rm "$SDK_TAR.tgz"
export ANDROID_HOME=$PWD/android-sdk-linux
export PATH="$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$PATH"
(while sleep 3; do echo "y"; done) | $ANDROID_HOME/tools/android update sdk -u
echo "y" | android update sdk --no-ui --all --filter tools,platform-tools,build-tools-$BUILD_TOOLS_VERSION > step1.log
echo "y" | android update sdk --no-ui --all --filter extra-android-m2repository,extra-android-support,extra-google-analytics_sdk_v2,extra-google-google_play_services_froyo,extra-google-google_play_services,extra-google-m2repository > step2.log
echo "y" | android update sdk --no-ui --all --filter android-$ANDROID_SDK,sysimg-$ANDROID_SDK,addon-google_apis-google-$ANDROID_SDK > step3.log
#
# Setup gradle
touch local.properties
echo "sdk.dir=$ANDROID_HOME" >> local.properties
chmod u+x ./gradlew
#
# Build
./gradlew assembleDevelop
When I push my repository and launch the compilation the following error occurs during compilation:
Warning: License for package Android SDK Build-Tools 27.0.3 not accepted.
FAILURE: Build failed with an exception.
occurred configuring project ':app'.
> Failed to install the following Android SDK packages as some licences have not been accepted.
build-tools;27.0.3 Android SDK Build-Tools 27.0.3
To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html
Using Android SDK: /home/rof/clone/android-sdk-linux
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 20s
In principle the lines echo "and" | android update sdk --no-ui --all - filter tools, platform-tools, build-tools- $ BUILD_TOOLS_VERSION> step1.log
should solve this problem. Someone can tell me what is missing in my script to perform the compilation successfully.
Thank you!!!