Sourcehut Android Gradle Continuous Integration

Published 2019-11-14 on Anjan's Homepage

Introduction to Sourcehut

Sourcehut is my git hosting platform of choice. Sourcehut offers a continious integration platform called Here is how to setup to compile android projects with gradle.


Before we begin, we need to create the android-sdk-license build secret. This file will tell the android build service (gradle in this guide) that you have agreed to all the required licenses for the dependancies upon which your project depends.

If you have built your android apps on your pc, you already have this file and are ready to go. Open up build secrets. Select Secret Type: File and enter the following details for your new secret:

Name: androidLicense

Path:  ~/android/licenses/android-sdk-license

Mode: 644

Click browse and navigate to where you have installed the android sdk on your local machine. Upload the file called android-sdk-license in the folder licenses.

Finally, in build secrets, click Add Secret.

On the right pane, a new secret should appear. There should be a UUID that represents the license file you just uploaded. When you include this UUID in your build manifest, android-sdk-license will be copied to the correct folder in your build environment.

If you would like to send your built apks to a vps, make sure you add your ssh config (nonstandard ports) and a new ssh private key to your secrets.


Finally, we have to make the .build.yml file on the root of your git repository on your local machine. You can use to lint and check whether your app will build on a clean machine with the latest version of gradle (build). I take it one step further and upload my unsigned build to my vps (deploy). This creates fresh unsigned builds for the latest commit of my app.

Here is my .build.yml from my own project lift: a free software workout app.

# I use archlinux for my image because I want to test whether my app
# builds with the latest release of gradle. Features are often deprecated on
# android and I did not know that my app was using alot of deprecated features
# until I tried to build with the latest version of gradle.
image: archlinux
  - gradle
  - rsync
# The git repo that contains my application. Enter your own app's git repo here
# UUIDs for ssh and android license secrets
  - 88e37d5a-6a50-4a14-b9d5-a944dc17bf50
  - b0ee6bc9-84d5-4962-a8cb-fc0a9e002bfa
  - 336f1246-50a2-464a-b3fe-1b54cba37a45
# Tell builds to send me an email if the build fails
  - action: email
    condition: failure
    to: Anjandev Momi <anjan -at->
  - build: |
      export ANDROID_SDK_ROOT=~/android
      cd lift
      gradle assemble
  - deploy: |
      cd lift/app/build/outputs/apk/debug
      sshopts="-o StrictHostKeyChecking=no"
      rsync --rsh="ssh $sshopts" -rP . ${deploy}:/srv/http/android/android

Finally, add this file in git, commit, and push to Your build should begin!

Installing the rsynced app

Be advised, you will not be able to install the apk that is rsynced by your .build.yml until you sign it using something like jarsigner. I do not sign my latest commit builds because they are strictly for myself.

You could generate a keystore using jarsigner, upload it as a secret to build secrets, and then add a couple extra lines before rsyncing to sign the app using jarsigner. However, I would prefer to use fdroid’s build tools at that point. Please do not store large files on - use a different git host. The documentation for fdroid’s build tools are here: f-droid: publishing nightly builds

When supports large files, I will write a blog post about using f-droid build tools on

Have a comment on one of my posts? Start a discussion in my public inbox by sending an email to ~anjan/ [mailing list etiquette]

Articles from blogs I follow around the net

These articles/blogs do not represent my own opinions or views.

Todo.txt-more: Efficiently managing your todo list and your time

Todo.txt More: Efficiently managing your todo list and your time Introduction I tend to get fairly enthusiastic when it comes to lists, even more so when there's a chance to optimise my productivity. The end of the year is a time for looking backward an…

via Proycon's website December 31, 2022

The PineTab2 is a new, faster Linux tablet - and it's not alone

In their December update, Pine64 announced the PineTab2, which is the successor to their PineTab from 2018. As a major change, the PineTab2 upgrades the slow A53-based A64 SoC with an A55-based Rockchip RK3566, the same chip that was used for the Quartz64…

via TuxPhones - Linux phones, tablets and portable devices December 19, 2022

I shall toil at a reduced volume

Over the last nine years I have written 300,000 words for this blog on the topics which are important to me. I am not certain that I have much left to say. I can keep revisiting these topics for years, each time adding a couple more years of wisdom and impro…

via Drew DeVault's blog December 1, 2022

Generated by openring