This post will describe how to compile a small application written in Kotlin using Bazel, tests, as well as how to use static analyzers. Phosphorus Phosphorus is the application that this post will cover. It’s a small utility that I wrote to check if an image matches a reference. If it doesn’t, Phosphorus generates an image highlighting the differences. The goal is to be able to check that something generates an image in a given way, and doesn’t change - at least if it’s not expected.
In this post, we’ll cover what Bazel is, how to use it, and why I chose to use it. What is Bazel? Bazel is a build-system released by Google in 2015. It actually is derived from the internal build-system Google uses internally for most of its own code-base, called Blaze. Building at scale Bazel has a huge focus on hermetic builds, and reproducibility. Every build step is, from a really broad perspective, defined as a list of inputs, tools, and outputs.
This blog has been inactive for a long time. I tried to at least post an article yearly, and next thing you know, two years and a half fly by… Halloween seemed like a good time to resurrect it. I wanted to start writing again recently, and faced an issue: this blog was using Octopress 2. Well, Octopress has apparently been dead for even longer than this blog. So I wanted to switch to another static generator.
Compat libraries are great. They allow us to work with newest Android APIs, without thinking (much) about your minimum API level. Instead of thousands of devices, you can reach billions. With nearly no changes in your code. But sometimes, they’re not so great…
What is Android Things? Android Things is an alternative Android version, announced at Google I/O 2015, and released as a first developer preview in December 2016. Its purpose is to develop embedded IoT devices, with a known and widely documented Android ecosystem basis. It’s currently running on three different boards: the Intel Edison, the NXP Pico i.MX6UL, and the Raspberry Pi 3. Some higher-end boards are coming soon. On the SDK side, Android Things comes with a specific support library to ease low-level hardware usage. It consists in two parts: the Peripheral I/O API, which supports GPIO, PWM, I2C, SPI and UART, and the User Driver API, which allows a developer to write a hardware-specific, high-level driver, to ease hardware reusability by injecting events into the Android framework. Other applications can in turn use those events without having to interact with the hardware directly. There’s a down side: the bundled Android is not as complete as the one you can find on a phone. Most of the standard applications aren’t installed (Calendar, Phone…), and standard content providers are absent too (MediaProvider, Dictionary…). Android Things supports displays, with the default Android UI toolkit. However, the display is a little bit different from what you’re used to see on an Android device: there’s no notification bar, navigation bar or anything, the running application will use the full display. That is, if it uses it at all: displays are purely optional.