About Talks Articles

Building Android Apps on Azure Pipelines

3 min read

Azure Pipelines emerged as a new compelling all-in-one solution for continuous integration. How difficult is it to use it to compile, build, and package an Android app? Apparently, not difficult at all.

To follow along, check out the sample repository at This is a minimalistic Android app in the style of the Hello World tradition. The principles however still apply to a complicated app.

The key here is the configuration file (in YAML format) for Azure Pipelines:

  vmImage: 'macOS 10.13'

- task: Gradle@2
    workingDirectory: ''
    gradleWrapperFile: 'gradlew'
    publishJUnitResults: false
    tasks: 'assembleDebug'

First we have to choose where to build. In the above case, it is a hosted macOS machine (maintained by Azure), identified by macOS 10.13 which has all the necessary SDKs to build mobile apps (not only Android, but also iOS).

After that, we invoke Gradle as usual, thereby running the typical build process of an Android app.

Azure Pipelines

To give it a try, fork the sample repository and set up Azure Pipelines plan from GitHub Marketplace. This is an easy one-time step. Once your Azure Pipelines project is created, create a new pipeline with the GitHub repository as the source. Automatically the config file azure-pipelines.yml will be detected. Click the Run button and now your app is being built. TYou should enjoy something like the following example build log.

From this onwards, you will get an email notification for every completion of the build.

Obviously, the important aspect of such a build notification is for feature branches, e.g. as part of a pull request. For every pull request, the status of the build (from Azure Pipelines) will be shown on the pull request page, making it easy to track if the change actually caused some problems or not.

Broken Pull Request

In addition to checking the build, of course we might want to try out the build packages. To do that, some more lines are necessary in the config file:

- task: CopyFiles@2
    contents: '**/*.apk'
    targetFolder: '$(build.artifactStagingDirectory)'

- task: PublishBuildArtifacts@1
    pathToPublish: '$(build.artifactStagingDirectory)/app/build/outputs/'
    artifactName: 'apk-files'
    artifactType: 'container'

Here we simply save some files, i.e. with the right glob pattern, and archive them as part of the build artifacts. Once each build is completed, there is a blue button Artifacts which can be used to peek at the contents of the artifact, as well as downloading the said apk files. Sideload the apk file to an Android emulator or a real device and you will be able to test drive it!

With this easy setup with Azure Pipelines, we shall not have any more excuses not to log the build process and to keep the artifacts of all revisions and important branches!

Related posts:

♡ this article? Explore more articles and follow me Twitter.

Share this on Twitter Facebook

comments powered by Disqus