# 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: [GitLab](<https://devfeed.tech/topics/gitlab.md>), [Android](<https://devfeed.tech/topics/android.md>), [ci](<https://devfeed.tech/topics/ci.md>), [SDK](<https://devfeed.tech/topics/sdk.md>), [Command-line interface](<https://devfeed.tech/topics/cli.md>), [Testing](<https://devfeed.tech/topics/testing.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-testing](<https://devfeed.tech/tags/android-testing.md>), [androiddev](<https://devfeed.tech/tags/androiddev.md>), [command-line](<https://devfeed.tech/tags/command-line.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>), [sdk](<https://devfeed.tech/tags/sdk.md>), [unit-testing](<https://devfeed.tech/tags/unit-testing.md>)

## AI overview

A tutorial for configuring GitLab CI for Android projects. It explains installing Android command-line tools and SDK packages, transferring accepted licenses to a CI server, and handling emulator limitations when running 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: -