Configure Bitbucket Pipelines for Android Projects

Siva Ganesh Kantamani
7 min readJun 29, 2022
Photo by T K on Unsplash

Introduction

Android development has seen rapid growth over the years, but when it comes to build times it would still take a considerable amount of time. No matter the RAM or the M1 chips, the android studio still finds a way to run out of memory.

Build time is one of the problems, then comes the process of uploading the APK on slack to make it accessible for the QA team. Things like this are routines, meaning — can be automated, and save developers time to focus on the things that actually matter.

This is where the CI/CD comes to light, CI/CD is nothing but continuous integration and continuous delivery. In this article, we’re going to use Bitbucket pipelines to implement CI/CD for an android project and automate the process of posting an APK on a slack channel.

Pre-Requests

A simple android project which is hosted on Bitbucket. We don’t need any premium account, bitbucket offers fifty free minutes of build time to run pipelines per month, it’s more than enough to get started.

Enable Pipeline

Once the repository is set up in the Bitbucket, the next step is to enable the bitbucket pipeline for the repository. Follow the below steps to enable the pipelines:

  1. Navigate to the repository, and click the Repository settings option in the left panel.
  2. Once you navigated to the repository details page, in the left panel click on settings under the PIPELINES section.
  3. Then you’ll be navigated to the Pipeline settings page where you can select the toggle to enable the pipeline.

That’s all Bitbucket pipelines are active on the repository now.

Configure bitbucket-pipelines.yml

Before getting into the configuration, one important matter to notice is that Bitbucket pipelines execute in Docker containers. To run/build the android project, we’re going to use Docker for Android SDK 30 with preinstalled tools from the Docker hub.