Waydroid

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.

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

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". 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

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

Initialize Waydroid either by launching the graphical app, or with. 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

You can also let the container start on boot automatically:

"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): 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:

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

Run apps from the command-line:

See  for more information.

Networking
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  interface):

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

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:

You most likely don't have the loop kernel module loaded or enabled. Try. 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: Then go to line 111 and comment the following line:

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.

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,  should work as a temporary fix.

Related

 * Waydroid documentation
 * Mobian Wiki: Waydroid
 * lets package it for postmarketOS
 * main/linux-postmarketos-*: enable CONFIG_PSI (with side-by-side performance video)