Anbox

From ArchWiki
Jump to navigation Jump to search

Anbox is a container-based software for running Android on GNU/Linux distributions.

Installation

Note: The dkms modules don't work on recent kernels (>=5.7) anymore! See Issue 49 on Anbox Github Repo for details.

Follow the instructions below instead.

For older kernels see Anbox#Older_kernels.

1. Install (or build) required kernel:

Anbox needs a kernel with specific config options enabled.

You have two options:

2. Enable binder and ashmem:

Run as root or with sudo:

$ modprobe binder_linux ashmem_linux

3. Install anbox:

Note: It seems the PKGBUILD file for anbox-git still includes the anbox-modules-dkms-git package. So modify the PKGBUILD file and build + install only the anbox-git package.

Install anbox-gitAUR.

Install one of these images:

Start/enable the following services:

  • anbox-container-manager.service
Note: There have been cases of conflicting packages while Installing anbox-gitAUR.

So make sure you install an Android Image first and then proceed to install the other Anbox packages.

See this link if you run into a common logger.cpp error.

Older kernels

On kernel versions below (<)5.7 the dkms modules still work.

1. Install linux-lts and linux-lts-headers.

2. Then build and install anbox-modules-dkms-gitAUR.

Note: For now the PKGBUILD includes two packages, so anbox-gitAUR will be built as well.

3. Install anbox-gitAUR.

4. Install one of these images:

5. Load kernel modules manually (optional):

If you don't want to reboot your computer to enable the required DKMS modules, you can load them manually:

$ modprobe ashmem_linux binder_linux

6. Enable the following services:

 anbox-container-manager.service

Network

systemd-networkd

The package anbox-gitAUR uses systemd-networkd to enable networking in anbox.

Therefore you need to enable systemd-networkd or start systemd-networkd before starting anbox-container-manager.service.

anbox-bridge script

Alternatively you can use the anbox-bridge script from https://raw.githubusercontent.com/anbox/anbox/master/scripts/anbox-bridge.sh

You must execute anbox-bridge every time before starting anbox-container-manager.service in order to get network working in anbox.

The easiest solution is create a drop-in file enable-anbox-bridge.conf.

/etc/systemd/system/anbox-container-manager.service.d/enable-anbox-bridge.conf
[Service]
ExecStartPre=/usr/bin/anbox-bridge start
ExecStopPost=/usr/bin/anbox-bridge stop

Usage

You can run the Android applications on your desktop's launcher on Other category.

If you want to use adb to debug, install android-tools

$ adb shell

Installing apps through adb

Unless you picked an image with houdini, Anbox doesn't have support for ARM applications. So apps must have a x86_64 architecture.

To install /path/to/app.apk

$ adb install /path/to/app.apk

To get the list of installed applications

$ adb shell pm list packages

Note that output will be similar to package:app.name, where app.name is different from the one displayed in anbox container.

To uninstall app.name

$ adb uninstall app.name

If app.name is a system app

$ adb uninstall --user 0 app.name

Installing apps through apps stores

Apps can be easily installed through apps stores. In anbox-image-gappsAUR PlayStore is included.

Tips and tricks

Rebuild kernel with necessary options

If you don't want to use the linux-zen kernel, you can rebuild the kernel:

Note: Rebuilding the kernel might take a very long time!

1. Build the kernel with these config options added/modified:

config
CONFIG_ASHMEM=y 
CONFIG_ANDROID=y
CONFIG_ANDROID_BINDER_IPC=y
CONFIG_ANDROID_BINDERFS=y
CONFIG_ANDROID_BINDER_DEVICES="binder,hwbinder,vndbinder"

2. Reboot into the new kernel.

3. Enable binder:

Note: This step might not be necessary. Discuss in Talk:Anbox.
# mkdir /dev/binderfs
# mount -t binder binder /dev/binderfs

Troubleshooting

If you run into issues, take a look at the official Issue Tracker: https://github.com/anbox/anbox/issues

Old CPUs

Anbox requires support for SSE 4.1/4.2 and SSSE 3, because Android wants that too. Some older CPUs don't provide that, so you probably can't use Anbox, see: Anbox Github Issue 499.

SecureBoot error

If you get this error message:

 modprobe: ERROR: could not insert 'ashmem_linux': Operation not permitted

Secure_Boot is likely blocking the module. You can either disable SecureBoot or sign the ashmem module yourself.

More info can be found in the Anbox Github Docs.

See also