# Setting up GitLab CI for Android Projects

DevFeed: [Setting up GitLab CI for Android Projects](<https://devfeed.tech/articles/setting-up-gitlab-ci-for-android-projects-25867.md>)

Original publisher: [Read original article](<http://lordraydenmk.github.io//2017/setting-up-gitlab-ci-for-android/>)

Author: Stojan Anastasov

Published: 2017-12-03T00:00:00Z

Content type: tutorial

Language: en

Sources: [Stojan Anastasov's blog](<https://devfeed.tech/sources/stojan-anastasov-s-blog.md>)

Topics: [CI/CD](<https://devfeed.tech/topics/cicd.md>), [gitlab-ci](<https://devfeed.tech/topics/gitlab-ci.md>), [Continuous integration](<https://devfeed.tech/topics/continuous-integration.md>), [Android](<https://devfeed.tech/topics/android.md>), [GitLab](<https://devfeed.tech/topics/gitlab.md>), [Software Testing](<https://devfeed.tech/topics/software-testing.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [androiddev](<https://devfeed.tech/tags/androiddev.md>), [ci](<https://devfeed.tech/tags/ci.md>), [continuous-integration](<https://devfeed.tech/tags/continuous-integration.md>), [gitlab](<https://devfeed.tech/tags/gitlab.md>), [gitlab-ci](<https://devfeed.tech/tags/gitlab-ci.md>)

## AI overview

The excerpt explains that GitLab CI setup requires installing a runner and adding a `.gitlab-ci.yml` file at the repository root. For Android builds, it says an older template based on a 2016 guide no longer works with Google's changed command-line tools. The author replaces the older SDK tools download and extraction steps with a ZIP download and `unzip`, and describes copying the SDK `licenses` folder from a development machine to the CI server before installing packages. A sample project is linked, but the excerpt says the latest x86 emulator needs hardware acceleration, so the author skips functional tests.

## Source excerpt

My first experience with continuous integration was using Bitbucket in combination with Jenkins. I was pretty happy with my setup. Jenkins would run on every commit making sure my code compiles, run android lint and run my unit tests. I also set up continuous deployment using Fabric. Now, at work, we use GitLab as a code repository. GitLab also offers continuous integration. When we decided to start using continuous integration at work we decided to give GitLab a chance. It was already integrated with GitLab and to use it we just needed to install a runner. Using CI with GitLab is simple, after you install a runner you need to add a .gitlab-ci.yml file at the root of the repository. GitLab even offers template .gitlab-ci.yml files for various languages and frameworks. The android template is based on this blog post from 2016. It is a great guide but unfortunately today it doesn't work. Google introduced a few changes in the command line tools. Installing Android SDK To install the Android SDK on a CI we need to install the command line tools (scroll to the bottom to Get just the command line tools). The command line tools include the sdkmanager - a command line tool that allows you to view, install, update, and uninstall packages for the Android SDK. So instead of - wget --quiet --output-document=android-sdk.tgz https://dl.google.com/android/android-sdk_r${ANDROID_SDK_TOOLS}-linux.tgz - tar --extract --gzip --file=android-sdk.tgz we can use - wget --quiet --output-document=android-sdk.zip https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip - unzip -q android-sdk.zip -d android-sdk-linux to download and install the Android SDK tools. There is also an improvement in accepting licenses for the Android SDK. After you accept the licenses on your development machine the tools will generate a licenses folder in the Android SDK root directory. You can transfer the licenses from your development machine to your CI server. To accept the licenses we can use: -