Anbox

Android emulator for running apps on Linux

Anbox is not (and probably never will be) officially supported by the Mobian project. It is not available in Mobian repositories nor in the Debian “main” archive, which are the only ones enabled by default.

Please keep in mind you will run into issues and report those directly to upstream.

Here be dragons.

Scale to fit:

App ID:

anbox

automatic-app-scaling

Phone Compatibility:

3/5, functional problems are not Mobian specific but Anbox itself

How to install:

To enable Anbox, you will need to first enable the contrib repo by running sudo sed -i “/main/ s/$/ contrib/” /etc/apt/sources.list and then sudo apt update

Then, sudo apt install anbox adb

Then download a working arm64 Android image, one can be found here: http://alexmitter.org/downloads/anbox/anbox_image_builder_image/android.img

Move android.img to /var/lib/anbox/ (you must create this directory first)

Now you must create three systemd services files:

/etc/systemd/system/dev-binderfs.mount :

[Unit]
Description=binderfs

[Mount]
What=binder
Where=/dev/binderfs
Type=binder

[Install]
WantedBy=anbox-container-manager.service

/etc/systemd/system/anbox-container-manager.service :

[Unit]
Description=Anbox Container Manager
Documentation=man:anbox(1)
After=network.target dev-binderfs.mount
Wants=network.target
Requires=dev-binderfs.mount
ConditionPathExists=/var/lib/anbox/android.img

[Service]
#ExecStartPre=/sbin/modprobe ashmem_linux
#ExecStartPre=/sbin/modprobe binder_linux
ExecStartPre=/usr/share/anbox/anbox-bridge.sh start
ExecStart=/usr/bin/anbox container-manager --daemon --privileged --data-path=/var/lib/anbox
ExecStopPost=/usr/share/anbox/anbox-bridge.sh stop

[Install]
WantedBy=multi-user.target

/etc/systemd/user/anbox-session-manager.service :

[Unit]
Description=Anbox Session Manager
Documentation=man:anbox(1)
After=basic.target
Wants=basic.target

[Service]
ExecStart=/usr/bin/anbox session-manager
Restart=on-failure
RestartSec=5s

[Install]
WantedBy=graphical-session.target

and create /usr/local/sbin/mount_binderfs :

#!/bin/sh

if [ ! -d /dev/binderfs ]; then
        if ! mkdir /dev/binderfs; then
                exit 1
        fi
fi

if ! mountpoint -q /dev/binderfs; then
        mount -t binder binder /dev/binderfs
fi

and sudo chmod 755 /usr/local/sbin/mount_binderfs

Now run:

sudo systemctl daemon-reload && sudo systemctl restart anbox-container-manager.service && systemctl --user restart anbox-session-manager.service

Repo:

Alternate setup using the Librem5 fork

In four steps to the solution:

1. You need to modify /etc/apt/sources.list to include contrib and the source code repository for those packages:

deb http://deb.debian.org/debian bullseye main contrib
deb-src http://deb.debian.org/debian bullseye main contrib

2. Then install build dependencies, clone the repo, build and install:

sudo apt update
sudo apt install devscripts
sudo apt build-dep anbox
git clone https://source.puri.sm/Librem5/debs/anbox.git
cd anbox
debuild -b -us -uc
sudo dpkg -i ../anbox_0.0*.deb

3. On a PC (running a Debian-like OS), install build dependencies and generate the android.img image file:

sudo apt install docker.io squashfs-tools gcc
git clone https://source.puri.sm/sebastian.krzyszkowiak/anbox-image-builder.git
cd anbox-image-builder
./build
./assemble

4. Then, copy the android.img file to /var/lib/anbox/ and add this line to /etc/fstab:

none                                            /dev/binderfs   binder  nofail          0       0

After a reboot you should then be able to start Anbox from the launcher.