From postmarketOS Wiki
Note Consider using native Linux programs instead, see FAQ.

Waydroid is the modern approach to run Android apps on Linux. It is similar to Anbox, but it works with Wayland and is more performant. Waydroid is available in postmarketOS v21.12 and newer. Running Android apps on mobile Linux is still kind of experimental, so be prepared to deal with problems.


$ sudo apk add waydroid

Additional steps, or else the container won't start:

$ sudo rc-update add cgroups default # optional
$ sudo rc-service cgroups start
$ sudo apk add iptables dnsmasq

Make sure you have disabled CONFIG_RT_GROUP_SCHED from your kernel defconfig; on pmOS it is enabled by default.

If it is enabled this command should return "CONFIG_RT_GROUP_SCHED=y".

$ zcat /proc/config.gz | grep CONFIG_RT_GROUP_SCHED

Then proceed to disable it by recompiling and flash the kernel with pmbootstrap following the steps in kernel configuration. In menuconfig the option is in General setup ─> Control Group Support ─> CPU controller ─> Group scheduling for SCHED_RR/FIFO


After installation, the Waydroid session is configured to start automatically on boot.

Initialize Waydroid either by launching the graphical app, or with sudo waydroid init. This will download images and extract them, and will take some time to complete.

In order to run apps, the container needs to be started as well. (Apparently it should start automatically when running apps? Also it appears to take quite some time to start up.)

You can start the container and session as follows:

"Container" refers to the Android LXC container itself

$ sudo rc-service waydroid-container start

You can also let the container start on boot automatically:

$ sudo rc-update add waydroid-container default

"Session" refers to the Waydroid specific bits to integrate Android apps into your users environment (.desktop files etc). If it doesn't start up automatically on boot, you can launch it manually (and you have to do this if you stop the previously mentioned OpenRC service):

$ waydroid session start

Note that this command will not terminate after starting the session but will stay in the foreground, so either open a new terminal afterwards or send it to background via `nohup`.

Use the following command to inspect the status of Waydroid:

$ waydroid status
Session:        RUNNING
Container:      RUNNING
Vendor type:    MAINLINE
Session user:   user(10000)
Wayland display:        wayland-0

You can run the Android container in fullscreen (note that this isn't necessary to run apps):

$ waydroid show-full-ui

Run apps from the command-line:

$ waydroid app list
$ waydroid app launch com.android.settings

See waydroid -h for more information.



The container may not have access to the Internet out of the box. To access the network you need to allow access from and to the container via the firewall (otherwise DHCP will be blocked and the container will never get the IP) and configure a default gateway in the waydroid container (gateway IP is what your host device has on waydroid0 interface):

$ echo "ip route add default via" | sudo waydroid shell

If this fails with an error about an unreachable network, run:

$ sudo apk add waydroid-nftables

if you also see this error

RuntimeError: Command failed: % /usr/lib/waydroid/data/scripts/``waydroid-net.sh start
Warning: Extension udp revision 0 not supported, missing kernel module?

You need to install

$ sudo apk add iptables-legacy

Waydroid service not starting

Waydroid may take 15 - 20 minutes, with errors in logs during its initial boot. See https://forum.pine64.org/showthread.php?tid=15813 for more details.

Currently the Phosh build is using PulseAudio which will automatically suspend by default. This can prevent WayDroid from starting up or even randomly crash until PulseAudio is woken up again. If you are running into this, try playing some audio to keep Pulse awake (volume up/down every ~30 seconds works). Note that if your WayDroid service has been crashing, it may take 1-2 minutes to start up after waking Pulse. If you have confirmed that Pulse's suspend is causing issues, you can disable it by commenting out "load-module module-suspend-on-idle" (line 111) in /etc/pulse/default.pa. A reboot is recommended after updating the config.

Starting the Waydroid service

If you see something like this in your log:

(004537) [17:13:07] % sudo mount /usr/share/waydroid-extra/images/system.img /var/lib/waydroid/rootfs
mount: /var/lib/waydroid/rootfs: mount failed: Operation not permitted.

You most likely don't have the loop kernel module loaded or enabled. Try modprobe loop. If that doesn't work, make sure CONFIG_BLK_DEV_LOOP is enabled in your kernel.

Waydroid isn't launching

If your device uses Pulseaudio (I.E: You're on GNOME, Phosh or any GNOME fork), you're advised to:

$ nano /etc/pulse/default.pa   # [You can use any other text editor if you'd like]

Then go to line 111 and comment the following line:

load-module module-suspend-on-idle

↓ Becomes

#load-module module-suspend-on-idle

After this, you can restart your device (or Pulseaudio) and Waydroid should now "work". You'd have to nudge it by either connecting to a bluetooth speaker (or a computer running linux through bluetooth, they can act as speakers) or by playing audio, be it just making GNOME do the pop sound (volume rocker) or by playing something.

On GNOME mobile (not Phosh), as of March 30 on pmOS edge, doesn't seem to need the nudging previously mentioned.

RuntimeError Command failed

When you have issues similar to:

RuntimeError: Command failed: % mv /var/lib/waydroid/config_session /var/lib/waydroid/lxc/waydroid

the mentioned directory may not exist. Don't create it manualy, but run:

waydroid upgrade

Run 'waydroid log' for details

If every time you try to start a command as a non-root user nothing happens, and it prints "Run 'waydroid log' for details", it is due to the following bug, where the application crashed due to being unable to access the log. Until the fix is included in postmarketOS, sudo chown $(whoami) /var/lib/waydroid/waydroid.log should work as a temporary fix.