InSnh-Gd 的小空间

Build LineageOS 20 system for Waydroid.

As of 2024-04-04, which is the time this article was written, Waydroid only provides LineageOS 18 container images based on Android 11. However, Waydroid is preparing LineageOS 20, which can be found on GitHub. But it has not yet reached a fully functional level and there are still many issues, such as the apparent inability to use libndk translation and the inability to run arm64 games.

LineageOS 20 vendor:

TIPS: If you encounter any errors during the build process, you may be able to find your problem in the Troubleshooting section.


I use an X86 platform running Arch Linux as the device for compiling LineageOS.

Compiling lineage-20 requires 32GB or more of RAM and around 300GB of disk space (although we may not need such a large space for building Waydroid). You also need a network that can access GitHub (but you can also clone LineageOS source code from a mirror site in China, which we will use later).

Arch Linux needs to enable the multilib repository.

To fetch LineageOS source code, you need repo git.

$ sudo pacman -Sy repo git

Building LineageOS requires installing some build dependencies: bc bison base_devel ccache curl flex git git-lfs gnupg gperf imagemagick readline lib32-zlib lib32-libelf lz4 lib32-sdl12-compat openssl libxml2 lzop pngcrush rsync schedtool squashfs-tools libxslt zip zlib

You also need to install OpenJDK 11 and Python 3, which are required for building LineageOS 20.

$ sudo pacman -Sy bc bison base_devel ccache curl flex git git-lfs gnupg gperf imagemagick readline lib32-zlib lib32-libelf lz4 lib32-sdl12-compat openssl libxml2 lzop pngcrush rsync schedtool squashfs-tools libxslt zip zlib jdk11-openjdk python

Building LineageOS#

First, create a directory for building lineageos-20. Here, I'll use ~/l20 as an example.

$ mkdir ~/l20

Configure git#

Since using repo requires authentication to clone the lineage-20 repository, we need to configure git identity.

$ git config --global ""
$ git config --global "Your Name"

Make sure git lfs is available.

$ git lfs install


Initialize the local repository:

$ repo init -u -b lineage-20.0 --git-lfs
$ repo sync build/make

Get Waydroid local_manifests:

$ wget -O - | bash


Sync the source code. This may take over an hour:

$ repo sync

Then configure the local build environment:

$ . build/


Apply Waydroid patches:

$ apply-waydroid-patches

Start building#

Waydroid AOSP lunch has the following options:


Since I'm using the X86_64 platform, I'll use the lineage_waydroid_x86_64-userdebug option.

Next, start the build:

. build/
lunch lineage_waydroid_x86_64-userdebug
make systemimage -j$(nproc --all)
make vendorimage -j$(nproc --all)

Note that -j$(nproc --all) will use all your threads. If you encounter out-of-memory errors during compilation, it is recommended to use fewer threads.

This will be a long process. I have an AMD Ryzen R5 7600X + 16GB RAM configuration, and the first build takes about 3-4 hours.

By default, AOSP builds "Android Sparse Image" images, but we need raw filesystems (img) format images. So we need to convert the output images to the system.img and vendor.img that we need.

$ simg2img $OUT/system.img ~/system.img
$ simg2img $OUT/vendor.img ~/vendor.img

You can find the output images in your HOME directory.

Using the custom built images#

We need to copy our custom images to /usr/share/waydroid-extra/images/

$ sudo mkdir -p /usr/share/waydroid-extra/images
$ sudo cp ~/system.img /usr/share/waydroid-extra/images
$ sudo cp ~/vendor.img /usr/share/waydroid-extra/images

Then initialize Waydroid

sudo waydroid init -f 

Now we can use LineageOS 20 on Waydroid~

Here are some screenshots:




Git-LFS not working properly#

FAILED: Verifying uses-libraries: external/chromium-webview/prebuilt/arm64/webview.apk
Outputs: out/target/common/obj/APPS/webview_intermediates/enforce_uses_libraries.status
Error: exited with code: 1
Command: /bin/bash -c "(rm -f out/target/common/obj/APPS/webview_intermediates/enforce_uses_libraries.status ) && (build/soong/scripts/ --enforce-uses-libraries --enforce-uses-libraries-status out/target/common/obj/APPS/webview_intermediates/enforce_uses_libraries.status --aapt out/host/linux-x86/bin/aapt external/chromium-webview/prebuilt/arm64/webview.apk )"
zipro W 03-18 08:22:10 595921 595921] Error opening archive external/chromium-webview/prebuilt/arm64/webview.apk: Invalid file
ERROR: dump failed because no AndroidManifest.xml found
�[1;31merror:�[0m Command '['out/host/linux-x86/bin/aapt', 'dump', 'badging', 'external/chromium-webview/prebuilt/arm64/webview.apk']' returned non-zero exit status 1

If you encounter the above error during the build, first check if Git-LFS is installed and working properly in your environment.

$ git lfs install
Git LFS initialized.

If it doesn't return initialized, you need to reinstall Git LFS and fetch the files that require Git-LFS from the source code again.

$ repo sync -c
$ repo forall -c 'git lfs pull' 

You may also need to reapply Waydroid patches.

$ apply-waydroid-patches

During this process, there may be some patch conflicts. Simply sync the source code again.

$ repo sync

Try building again.

. build/
lunch lineage_waydroid_x86_64-userdebug
make systemimage -j$(nproc --all)
make vendorimage -j$(nproc --all)


This article is synchronized and updated to xLog by Mix Space.
The original link is

Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.