13

Run Android Operating System on Linux using Waydroid

 2 years ago
source link: https://computingforgeeks.com/run-android-operating-system-on-linux-using-waydroid/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Run Android Operating System on Linux using Waydroid
Search

In day-to-day life, people find themselves in situations where they want to run android on desktop computers. There are many ways to run android apps on a computer with emulators such as Bluestacks being popular, you can also run android on as a virtual machine e.t.c. Among those many methods, there is Anbox a solution to run android apps on Linux-based systems, but now it is not as great as such since it suffers from slow performance on low power devices. Now there is a project that completely solves this slow performance and jank experienced in Anbox. This project is called WayDroid, formerly referred to as Anbox-Halium which is a rebuild of Anbox, intended to use more of the native host’s hardware resulting in faster performance as compared to Anbox. WayDroid uses a customized Android system image based on the LineageOS. This provides an up-to-date version of Android and allows developers to add their own tweaks with a lot of apps available for them. WayDroid has the following features:

  • Desktop Integration- Allows the adroid apps to run side by side with the native host’s applications
  • Supports multi window mode when running android apps
  • It supports shortcuts for android applications on the host’s standard menu
  • Supports running android applications in full screen mode such as android games e.t.c
  • It uses the native host’s kernel thus running android apps smoothly

This guide demonstrates how to run an Android Operating System on a Linux system using Waydroid.

Step 1: Install Dependencies required

Let’s begin by updating of system’s package index.

sudo apt update

Then install the required dependencies i.e Pyhton3, Wayland session manager, curl, and LXC on our Ubuntu/Debian system as below.

##For Ubuntu
sudo apt install python3 lxc curl gnome-session-wayland

##For Debian
sudo apt install python3 lxc curl vim

Then enable Wayland on Nvidia drivers in Ubuntu/Debian as below.

sudo vim /lib/udev/rules.d/61-gdm.rules

Find and comment (#) all the lines as below.

# ATTR{vendor}=="0x19e5", ATTR{device}=="0x1711", RUN+="/usr/lib/gdm3/gdm-disable-wayland"
........
# DRIVER=="nvidia", RUN+="/usr/lib/gdm3/gdm-disable-wayland"

Also in the gdm3 conf file, enable Wayland desktop as below.

##On Ubuntu
sudo vim /etc/gdm3/custom.conf

##On Debian 
sudo vim /etc/gdm3/daemon.conf

In the file, ensure that the line below is commented.

#WaylandEnable=false

Step 2: Enable Wayland on Gnome

Set the runtime Gnome session to Wayland by disabling Gnome x11 sessions as below.

sudo mv /usr/share/xsessions/gnome.desktop /usr/share/xsessions/gnome.desktop.disbaled

You are then required to log out of the system and log in to Gnome or Ubuntu Wayland desktop by clicking on the cogwheel.

View other available Wayland sessions as below:

$ ls /usr/share/wayland-sessions
gnome.desktop  ubuntu-wayland.desktop

Then check the session type as below. It should now be set to Wayland.

$ echo $XDG_SESSION_TYPE
wayland

Step 3: Install Waydroid on Linux System

Before we install WayDroid on our Linux system, we need to add the repositories to our system. Remember to replace the Disro=”focal” with your target OS e.g bullseye, hirsute, buster e.t.c

For ubuntu 20.04 LTS (focal)

export DISTRO="focal" && \
sudo curl https://repo.waydro.id/waydroid.gpg --output /usr/share/keyrings/waydroid.gpg && \ 
echo "deb [signed-by=/usr/share/keyrings/waydroid.gpg] https://repo.waydro.id/ $DISTRO main" > ~/waydroid.list && \
sudo mv ~/waydroid.list /etc/apt/sources.list.d/waydroid.list && \
sudo apt update

For Debian 11 (bullseye)

export DISTRO="bullseye" && \
sudo curl https://repo.waydro.id/waydroid.gpg --output /usr/share/keyrings/waydroid.gpg && \ 
echo "deb [signed-by=/usr/share/keyrings/waydroid.gpg] https://repo.waydro.id/ $DISTRO main" > ~/waydroid.list && \
sudo mv ~/waydroid.list /etc/apt/sources.list.d/waydroid.list && \
sudo apt update

With the repository added to your system as above, now install WayDroid on Ubuntu|Debian with the command:

sudo apt install waydroid

Start the Waydroid init process as below.

sudo waydroid init

In case the process fails due to lack of device nodes located at /dev you will be required to create and mount them as below

##Binderfs
sudo mkdir /dev/binderfs
sudo mount -t binder binder /dev/binderfs

##hwbinder
sudo mkdir /dev/hwbinder
sudo mount -t binder binder /dev/hwbinder

##vndbinder
sudo mkdir /dev/vndbinder
sudo mount -t binder binder /dev/vndbinder

Then re-run the command below:

sudo waydroid init

Sample Output:

[13:41:42] Download https://sourceforge.net/projects/waydroid/files/images/system/lineage/waydroid_x86_64/lineage-17.1-20210928-VANILLA-waydroid_x86_64-system.zip/download
[13:48:20] Validating system image
[13:48:24] Extracting to /var/lib/waydroid/images
[13:49:52] Download https://sourceforge.net/projects/waydroid/files/images/vendor/waydroid_x86_64/lineage-17.1-20210928-MAINLINE-waydroid_x86_64-vendor.zip/download
[13:51:35] Validating vendor image
[13:51:36] Extracting to /var/lib/waydroid/images

Step 4: Start and use WayDroid on Linux

Now that Waydroid has been installed on your Debian/Ubuntu system, start the WayDroid container service as below

sudo systemctl start waydroid-container

Alternatively, you can start Waydroid manually without systemctl using the command below:

### Launch the container manually
sudo waydroid container start

Then start the wayDroid session.

waydroid session start

You should see the output below once the session starts:

[14:16:32] Android with user 0 is ready
.........

Check the Waydroid status:

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

While here, it is safe to launch an app from the app menu as below.

Launching WayDroid app in full mode

You can proceed and launch the WayDroid app in full mode. Remember to execute the commands without sudo.

$ waydroid show-full-ui
[15:00:43] Starting waydroid session
........

At this point, Waydroid should be running smoothly and will be displayed in full mode as below.

Launch apps by swiping up using your mouse:

You can proceed and install desired applications (apk files) by downloading them from the browser. Then allow installation as below.

Once installed, your new applications should appear as below.

Now you have your android system running on Linux, verified by checking the OS version.

You can also launch Wayroid in Multi-window mode with the command:

waydroid prop set persist.waydroid.multi_windows true

After that, you need to restart the container as below.

sudo systemctl restart waydroid-container

Step 5: How To Reinstall Waydroid

In case there is a step you got wrong when installing Waydroid and you want to reinstall it, go through the following steps.

Stop the Waydroid session and container first.

waydroid session stop
sudo waydroid container stop

Then uninstall Waydroid as below:

sudo apt remove waydroid

You will then need to reboot your device and do a little clean-up as below.

sudo rm -rf /var/lib/waydroid /home/.waydroid ~/waydroid ~/.share/waydroid

Then reinstall Waydroid as below.

sudo apt install waydroid
sudo waydroid init

That is it! We have successfully installed Waydroid on our Linux system, you can now easily run android apps on your Linux desktop. I hope you enjoyed this.

See more on this page:


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK