Continuous Integration with Github, Android and CircleCI

Continuous Integration with Github, Android and CircleCI

Hello guys, today I will be writing about something new that I am learning. Lets look at CI. But before we look at it, I would like to express how excited I am to finally join Twiga Foods as an Android Engineer,  thanks to their wonderful C.T.O Mr Caine and their entire Development Team.

Continuous Integration (CI) plays an important role in the development process for almost every development team. Knowing the effects of your changes is extremely useful to see how the tasks are coming together with other members. It’s also just a good approach to take in general if you’re developing something personally and want to track the progress and stability of your project.

There’s a lot of CI tools available to anyone who needs it,  with Jenkins or TravisCI being the most recognized tools out there. CircleCI is a fresh take on CI that provides a very clean UI and powerful flexibility to users. Let’s take a look at setting up a basic CircleCI build task for an Android application.


  • A Github account (CircleCI also has BitBucket login option)
  • Android Studio – I’m using the 3.1 Canary  8 preview version.

Dipping your toes

I’m going to assume you already have an Android app up and running in Android Studio so I’ll skip that part. If you don’t have your application code in Github or another type of Version Control system, I would recommend you do that now. It can be a life-saver if things go bad and you can work on your code from anywhere.

The first thing we need is to create your CircleCI account. CircleCI is free to sign up to and use up to a certain limit (approx 1500 build minutes p/month) so it’s great for individuals. We’ll also be using a technique to speed up build times on CircleCI to reduce build times. When you sign in with your Github account, you’ll be able to choose which projects you’ll want to track / build. Select the project you want to follow and an initial build should trigger. CircleCI’s default configuration triggers a build to occur on any commit to any branch on the repository, but this can be customised later on. CircleCI fires up a container to host your app while it’s building.

Lets use this Repo from my Andela ALC Challenge, which you can folk and make contributions to 🙂


Follow the Next Steps section you see in your CircleCI, as shown in the screenshot above. After that, just push the changes to Github.

It’s probably best to switch to Project perspective in Android Studio for this part, as the file is hidden in the Android perspective.

After you are done pushing it, just hit the Start Building button on step 5. This triggers CircleCI as shown below:

As shown above, CircleCI is performing a build on the Master Branch.

After performing the first build, I got an error 🙂

So I googled my way around Stackoverflow and found this solution. Move the config.yml from the .circleci folder. I tried to rebuild again and got this build error.

The issue here is that we have not granted the correct permissions to the ./gradlew command on the container that CircleCI has created.

This configuration file informs CircleCI that when the dependencies section is reached, gradlew must be given execution permissions (chmod +x) This will allow ./gradlew to run, but it will fail for a different reason. To use the Android SDK and build tools, you must accept the licence agreements.

Passing the Test

The most important part of the above config file is ./gradlew assemble. This is what actually builds your project. Once you have this file in your project, your CircleCI build should be ready. My builds usually take about 4 minutes to complete, but it is somewhat dependent on how much you pay! Settings on CircleCI can be accessed which change when a build is triggered, such as only on pull requests. CircleCI also has email notifications, along with integrations for Slack channels so it’s a very modern and useful tool for Android development.

I am still learning a lot in CircleCI, so free free to shoot suggestions, tips and even questions down below. Remember to subscribe, follow me on Twitter and Facebook to get updates from me.

Happy Coding!

2 Replies to “Continuous Integration with Github, Android and CircleCI”

    1. Hello Romell,
      Please refer to number 2, on the right side where you have copy to clipboard.Thats how you get a yml for your specific project, or are you getting any error? If any, please share here :):)

Leave a Reply

Your email address will not be published. Required fields are marked *