by Sam Hadow
This blog post is a short guide to run and use waydroid on archlinux.
Waydroid is a container-based approach to boot a ful android system on a regular linux system with an x86 or ARM CPU, and so has less overhead than an android x86 virtual machine to run android apps on a linux system. Waydroid only works in a wayland session but it’s still possible to use a nested session if you use X11, which will be covered in this guide.
A kernel which comes with the rust_binder module is necessary to run waydroid, linux-zen kernel includes this module.
If you’re using another kernel you can add it via DKMS (note that you can use another aur helper than yay).
yay -S binder_linux-dkms
Then you can manually load it:
sudo modprobe binder-linux devices=binder,hwbinder,vndbinder
Or load it automatically at boot:
echo "binder_linux" > /etc/modules-load.d/binder_linux.conf
echo "options binder_linux devices=binder,hwbinder,vndbinder" > /etc/modprobe.d/binder_linux.conf
sudo pacman -S waydroid
If using X11, you’ll need to run a nested wayland session, a simple solution is using cage. You could also use weston.
sudo pacman -S cage
sudo waydroid init
Or with google apps support:
sudo waydroid init -s GAPPS
This command will automatically start the waydroid container and a session before showing the UI.
waydroid show-full-ui
Otherwise if you want a CLI, you have to start the container and then a session:
sudo systemctl start waydroid-container.service
waydroid session start
| Command | Purpose |
|---|---|
waydroid session start |
Starting a session |
waydroid session stop |
Stopping a session |
waydroid status |
Checking Waydroid status |
sudo waydroid upgrade |
Upgrading the LineageOS image |
waydroid app list |
Get the list of installed apps |
waydroid app install $path_to_apk |
Install an APK |
waydroid show-full-ui |
Launch the GUI |
waydroid app launch $package_name |
Launch an app |
sudo waydroid shell |
Launch a shell |
waydroid --help |
Display the help message |
On X11 waydroid container can be started but then all waydroid commands need to be run inside a nested wayland session.
If you just need waydroid UI the simplest is with cage:
cage -- waydroid show-full-ui
If you need the command line then you need to have a console running inside a wayland session. For example with Konsole:
cage -- konsole
You can then type the commands the same as described above.
You need some additional rules in your firewall if you want the network to work inside waydroid. For example with nftables you need these additional rules in your tables:
table inet filter {
chain input {
# -------------------------------- waydroid
iifname "waydroid0" accept comment "Allow incoming network traffic from WayDroid"
}
chain forward {
# -------------------------------- waydroid
iifname "waydroid0" accept comment "Allow incomming network traffic from WayDroid"
oifname "waydroid0" accept comment "Allow outgoing network traffic from WayDroid"
}
chain output {
}
}
You also need to enable packet forwarding. To check if it’s already enabled:
sysctl net.ipv4.ip_forward
sysctl net.ipv6.conf.all.forwarding
If it’s not enabled you can permanently enable it in the file /etc/sysctl.conf by uncommenting the lines net.ipv4.ip_forward=1 for IPv4 and net.ipv6.conf.all.forwarding=1 for IPv6. Please note that in most cases you can for now just enable the IPv4 packet forwarding and ignore the IPv6 one.
And to reload the configuration:
sudo sysctl -p /etc/sysctl.conf
If you want to share the clipboard between a wayland session and waydroid UI you need to install the packages python-pyclip and wl-clipboard.
It however won’t work with X11 and nested wayland sessions.
You might want to install aurora store, an open source google play store client not requiring a google account. And an F-Droid client like droidify.
If you have an Intel or AMD GPU it should work out of the box. But if you have a NVIDIA GPU you’ll need to enable software rendering. For that in /var/lib/waydroid/waydroid.cfg add the following:
[properties]
ro.hardware.gralloc=default
ro.hardware.egl=swiftshader
and then run:
sudo waydroid upgrade --offline
sudo systemctl restart waydroid-container.service
ARM apps won’t work at first if you have a x86 CPU, it’ll say the app is incompatible for your device when trying to install it. To use arm apps you need to install a translation layer. It’s recommanded to use libndk on AMD CPUs and libhoudini on Intel CPUs. To do that:
yay -S waydroid-script-git
sudo waydroid-extras install libndk
# or
sudo waydroid-extras install libhoudini
sudo systemctl restart waydroid-container.service
And if you’re interested in learning more about Intel houdini you can have a look at this presentation, and in video
By default waydroid shows AOSP on screen keyboard, which is useless on a computer with a keyboard already, to disable it the setting is in Settings > System > Languages & input > Physical keyboard > Use on-screen keyboard
This module is necessary for waydroid to work:
module local-waydroid-nft 1.0;
require {
type virtd_t;
type iptables_t;
class process { noatsecure rlimitinh siginh };
}
#============= virtd_t ==============
allow virtd_t iptables_t:process { noatsecure rlimitinh siginh };
You can compile it and load it with these commands (with the content above in a file local-waydroid-nft.te):
checkmodule -m -o local-waydroid-nft.mod local-waydroid-nft.te
semodule_package -o local-waydroid-nft.pp -m local-waydroid-nft.mod
semodule -i local-waydroid-nft.pp
And this script makes starting waydroid more convenient:
#!/bin/bash
sudo /usr/lib/waydroid/data/scripts/waydroid-net.sh start
cage -- waydroid show-full-ui
Finally you might want to check the archwiki directly if having issues with waydroid.
And although it’s quite old and contains some unecessary steps now, you can check this guide too.