Skip to content

Instantly share code, notes, and snippets.

@ssz66666
Last active January 4, 2021 09:49
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ssz66666/8422d46eae83ce7240f5547d129bf29c to your computer and use it in GitHub Desktop.
Save ssz66666/8422d46eae83ce7240f5547d129bf29c to your computer and use it in GitHub Desktop.
Building Anbox Android image on Arch Linux

Build Anbox Android image on Arch Linux

Introduction

This is a note for building the anbox Android image on my Arch Linux laptop.

This closely follows the official guide.

Install build dependencies

Following the wiki: https://wiki.archlinux.org/index.php/Android#Building

I use yay for AUR packages as an example:

$ yay -Syu aosp-devel

Download sources

The AOSP source is huge (over 100GB), so downloading can take a day or so.

It's possible to use a different AOSP source mirror, just modify the manifest xml, change fetch property of the aosp remote. If you followed the official guide, the manifest will be in the hidden .repo directory.

Building

As noted in the official guide, run the following commands before making:

$ . build/envsetup.sh
$ lunch anbox_x86_64-userdebug

You should temporarily change your default JDK to OpenJDK 8:

# archlinux-java set java-8-openjdk

To make those Python 2 build scripts work, we want to make

$ /usr/bin/env python

resolves to the Python 2 interpreter.

We can create a dummy path directory to achieve this.

$ cd ~
$ mkdir py2env
$ ln -s /usr/bin/python2 py2env/python

Then prepend your py2env to PATH.

Additionally we need to set LC_ALL=C to mitigate a known bug:

So the final make command:

$ PATH=~/py2env:$PATH LC_ALL=C make -j8

After a long build time, follow the guide to create the image (assuming workspace is at $HOME/anbox-work):

$ cd $HOME/anbox-work/vendor/anbox
$ ./scripts/create-package.sh \
    $PWD/../../out/target/product/x86_64/ramdisk.img \
    $PWD/../../out/target/product/x86_64/system.img

Note the official guide misses one ../.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment