Android development with Guix System in 2021

by Jelle Licht — Thu 15 July 2021

The majority of work shared in this post is based on work done by Julien Lepiller and shared on their blog. Go read that first if you want to understand what is happening here. Simply follow the instructions under TLDR if understanding is optional, and you just want to hit the ground running.

TLDR

See manifest.scm for the manifest, and container.sh for the container script to launch Android Studio in a container using Guix's environment subcommand.

bash container.sh

Be aware that the container that Android Studio will run in is poked full of holes to support kvm-powered emulation and communication with usb-connected (Android) devices.

Changes compared to Julien's approach

The most straightforward changes I made related to adding dependencies to the container manifest that are now required Android Studio dependencies.

I also made a guix package out of Android Studio itself. The licensing situation is a bit of a mess, and weirdly enough there is only one dependency that seems to be non-free software.

I also opened up some of the restraints on the container in which Android Studio will be running; most of this has to do with getting it to interact with Android devices connected over USB.

Remaining challenges

The current guix package definition for Android Studio is based on the copy-build-system , meaning that things are mostly just copied over.

Android Studio is one of those pieces of software that also helpfully phones home checks in at Google for updates; even worse, since the store is mounted read-only, these updates can not even be installed. It would be an improvement if we can disable or patch out this functionality entirely1

Starting a guix container by first building a profile, and only then entering a container is a bit of a hassle. I might still look into applying the same trick used to containerize Steam so the "Container Shuffle" can be hidden in day-to-day usage.

If you want to interact with USB-connected Android devices, make sure these devices are already connected when starting Android Studio: If you (re)connect a device while Studio is already running, DDMS will start freaking out and the only thing you can then still do is restart Studio.

Finally, Android Studio is (and will always be) a Google project; this practically also means that you will most likely be forced to read through heaps of EULAs, licenses and all that to even get started with the Android-equivalent of "Hello World". The fabled Someone should really look into getting it all to work using the actual Free Software rebuilds of the Android SDKs. Even better if they write a Guix package definitions for it as well.

Footnotes:

1

The ideal here would be to create a Guix Updater for making easy updates to the Android Studio Guix package expression.