Circle CI & Android: 8 advanced configuration tips

Ideas to improve your Circle CI configuration on android projects

Maxi Rosson
Dec 14, 2020 · 5 min read

1. Define executors for each resource class

Sometimes you need to quickly change the resource class you use on your job’s executor. For example, you could need to do that to measure the performance impact or because you need more memory/CPU.

You can simplify those changes by defining one executor per resource class. Each executor could have for example custom GRADLE_OPTS defined.

2. Unify Gradle user home path between different docker images

Not all the docker images use the same default user home path. Then, the Gradle user's home path can change between jobs. This can cause problems when saving/restoring caches on jobs with different home paths.

Some docker images allow you to override the Gradle user's home path.

3. Cache versioning

Versioning each cache key could be useful in certain situations:

  • If you need to clean up your cache, you can easily do that by just incrementing the cache key version number.
  • If you need to change the cache content to something not backward compatible with the previous one, you can increment the cache key version number and avoid conflicts.

4. Job caches instead of attach to workspace

You can have only one workspace per workflow to persist your files. If you have multiple big files persisted by different jobs, the attach_workspace step could take time. Sometimes a job doesn’t need to attach all the files on the workspace.

To solve that problem, you can use multiple caches instead of the workspace. You just need to use the pipeline & workflow ids as part of the cache key.

5. Store Junit Tests results

CircleCI collects test metadata from XML files and uses it to provide insights into your job.

Tests summary on CircleCI

To achieve that you just need to run the store_test_results step to upload the XML files after executing your Junit tests.

6. Store Firebase Test Lab results

You can also see the Firebase Test Lab Tests summary in the same way you can see Junit Tests.

You will need to send the results-dir flag to the gcloud command, so the Firebase Test Lab device can store the XML with the test results on that directory.

Then you can download the XML with the results of the tests, using the gsutil command.

7. Switch to Gradle Binary Distribution

In your development environment, you would like to use the -all Gradle distribution on your file, so your IDE has code-completion enabled and you can navigate to the Gradle source code.

But using -all increases your Gradle download times. So, using -bin in Circle CI is a better idea, because you don’t need the Gradle sources there.

The following step switches to Gradle Binary Distribution. It should be executed after the checkout step and before any Gradle execution.

8. Verify the integrity of the Gradle Wrapper JAR

The Wrapper JAR is a binary file that will be executed on the computers of developers and build servers. As with all such files, you should be sure that it’s trustworthy before executing it. Since the Wrapper JAR is usually checked into a project’s version control system, there is the potential for a malicious actor to replace the original JAR with a modified one by submitting a pull request that seemingly only upgrades the Gradle version. Here you can find more official information about this topic.

The following step verifies the checksum of the Wrapper JAR to ensure that it has not been tampered. You should execute it on each workflow.

Follow us for more productivity tools & ideas for Android, Kotlin & Gradle projects.


Boost your Productivity

Maxi Rosson

Written by

Developer Productivity Engineer | Android | Productivity tools & ideas for Android, Kotlin & Gradle developers on



Productivity tools & ideas for Android, Kotlin & Gradle developers.

Maxi Rosson

Written by

Developer Productivity Engineer | Android | Productivity tools & ideas for Android, Kotlin & Gradle developers on



Productivity tools & ideas for Android, Kotlin & Gradle developers.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store