You need at least 250 Gb free space on ssd.
Zram is recommended if less 16 Gb RAM
apt install -y zram-tools
find /etc/default/zramswap -type f -print0 | xargs -0 sed -i 's/.*PERCENT=.*/PERCENT=100/g'
systemctl restart zramswap.service
Based on official instruction from waydroid docs and lineageos wiki
Also used aosp_build for lineage 18.1 kernel and MindTheGapps for lineage 20.0
-
Prepare for build
git lfs install git config --global trailer.changeid.key "Change-Id" mkdir lineage-20.0 cd lineage-20.0 curl https://storage.googleapis.com/git-repo-downloads/repo > ~/.local/bin/repo chmod a+x ~/.local/bin/repo
-
Clone lineage vendor repo
repo init -u https://github.com/LineageOS/android.git -b lineage-20.0 --git-lfs repo sync build/make
-
Get waydroid vendor manifest
wget -O - https://raw.githubusercontent.com/waydroid/android_vendor_waydroid/lineage-20/manifest_scripts/generate-manifest.sh | bash
-
Mindthegapps part 1
If you don't want it, skip to step 5
Add block in the file:
nano .repo/manifests/default.xml
before the tag<remote name="MindTheGapps" fetch="https://gitlab.com/MindTheGapps/" /> <project path="vendor/gapps" name="vendor_gapps" remote="MindTheGapps" revision="tau" />
Correspondence of android version and branch name can be found in
build/gapps.sh
. Switch branches until you find the right version.
Android 13 is tau branch -
Sync repos
About 200 gigabytes of data will be downloaded
repo sync
-
Mindthegapps part 2
If you don't want it, skip to step 7
Add line in the end of this file:
nano device/waydroid/waydroid/device.mk
For x86_64:
include vendor/gapps/x86_64/x86_64-vendor.mk
For arm64:
include vendor/gapps/arm64/arm64-vendor.mk
Add line in the end of this file:
nano device/waydroid/waydroid/BoardConfig.mk
BUILD_BROKEN_ELF_PREBUILT_PRODUCT_COPY_FILES := true
-
Apply waydroid patches
. build/envsetup.sh apply-waydroid-patches
-
Apply custom patches
-
Only x86_64: BoardConfig: Reland scudo native allocator for x86 devices [PR]
curl https://patch-diff.githubusercontent.com/raw/waydroid/android_device_waydroid_waydroid/pull/4.patch | git -C device/waydroid/waydroid/ apply -v --index
-
[Don't use the patch is broken on lineage-20!] Add force_mouse_as_touch option. PR
If PR is already merged, this patch is no longer neededcurl https://raw.githubusercontent.com/YogSottot/waydroid_stuff/master/kernel_build/lineage-20.0/0001-patch-33-Force-mouse-event-as-touch-1-2.patch | git -C frameworks/base/ apply -v --index curl https://raw.githubusercontent.com/YogSottot/waydroid_stuff/master/kernel_build/lineage-20.0/0001-patch-33-Force-mouse-event-as-touch-2-2.patch | git -C frameworks/native/ apply -v --index
-
Add xmlconfig PR
If PR is already merged, this patch is no longer neededcurl https://raw.githubusercontent.com/YogSottot/waydroid_stuff/master/kernel_build/lineage-20.0/0001-patch-33-Enable-xmlconfig-on-Android.patch | git -C external/mesa/ apply -v --index curl https://raw.githubusercontent.com/YogSottot/waydroid_stuff/master/kernel_build/lineage-18.1/0001-patch-30-Enable-xmlconfig-on-Android-02.patch | git -C device/waydroid/waydroid/ apply -v
-
-
Install docker Documentation
Of course you can build images without a docker. The Dockerfile has a list of required dependencies.
-
Copy Dockerfile
wget https://raw.githubusercontent.com/YogSottot/waydroid_stuff/master/kernel_build/Dockerfile
Dockerfile based on this
-
Build Docker imagekernel
docker build -t waydroid-build-24.04 .
Build arguments
GIT_NAME
: Name to use for git commits. Default: "YogSottot"GIT_EMAIL
: Email to use for git commits. Default: "[email protected]"
PULL_REBASE
: Perform rebase instead of merge when pulling. Default: trueYou can pass build arguments to the build command like this:
docker build -t waydroid-build-24.04 . --build-arg GIT_NAME="John Doe" --build-arg GIT_EMAIL="[email protected]" .
If you want to use ccache, the create volume for it
mkdir -p /mnt/ccache/lineage-20.0 docker create -v /mnt/ccache/lineage-20.0:/ccache --name ccache-20.0 waydroid-build-24.04
-
Build system images
docker run -e CCACHE_DIR=/ccache --volumes-from ccache-20.0 -v $(pwd):/mnt/lineage -it waydroid-build-24.04 bash -c 'cd /mnt/lineage && ccache -M 50G && . build/envsetup.sh && lunch lineage_waydroid_x86_64-userdebug && make systemimage -j$(nproc --all)'
If you need
waydroid-arm64
, changelineage_waydroid_x86_64-userdebug
tolineage_waydroid_arm64-userdebug
.
A full list of options is available at commandlunch
. -
Build vendor image
docker run -e CCACHE_DIR=/ccache --volumes-from ccache-20.0 -v $(pwd):/mnt/lineage -it waydroid-build-24.04 bash -c 'cd /mnt/lineage && ccache -M 50G && . build/envsetup.sh && lunch lineage_waydroid_x86_64-userdebug && make vendorimage -j$(nproc --all)'
-
If you get the error:
/bin/bash: line 1: out/soong/.intermediates/prebuilts/build-tools/m4/linux_glibc_x86_64/m4: No such file or directory
then do this:cd out/soong/.intermediates/prebuilts/build-tools/m4/linux_glibc_x86_64/ ln -sf ../../../../../../../prebuilts/build-tools/linux-x86/bin/m4 . cd ../../../../../../../
-
If you get the error:
../subprojects/libarchive-3.7.2/libarchive/archive.h:101:10: fatal error: 'android_lf.h' file not found
then do this [PR]:curl https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27648.patch | git -C external/mesa/ apply -v --index
or
rm -f external/mesa/subprojects/libarchive.wrap
-
If you get the error:
xmllint.c:45:10: fatal error: 'readline/readline.h' file not found
then do this:rm -f external/mesa/subprojects/libxml2.wrap
Also you can create both images with a single command:
docker run -e CCACHE_DIR=/ccache --volumes-from ccache-20.0 -v $(pwd):/mnt/lineage -it waydroid-build-24.04 bash -c 'cd /mnt/lineage && ccache -M 50G && . build/envsetup.sh && lunch lineage_waydroid_x86_64-userdebug && make systemimage -j$(nproc --all) && make vendorimage -j$(nproc --all)'
-
-
Convert images
simg2img out/target/product/waydroid_x86_64/system.img ./system.img simg2img out/target/product/waydroid_x86_64/vendor.img ./vendor.img
or
docker run -v $(pwd):/mnt/lineage -it waydroid-build-24.04 bash -c 'cd /mnt/lineage && simg2img out/target/product/waydroid_x86_64/system.img ./system.img && simg2img out/target/product/waydroid_x86_64/vendor.img ./vendor.img'
-
Use images
Make a backup of old images beforehand
rsync -a /var/lib/waydroid /opt/waydroid_backups/
If you updated from lineage-18.1, then make a backup of user-dir
sudo rsync -a /home/user/.local/share/waydroid /home/user/.local/share/waydroid-18.1
Your images are in current dir [lineage-20.0] (system.img / vendor.img) You can use rsync to copy images to /var/lib/waydroid/images
rsync *.img /var/lib/waydroid/images/
If you installed the arm translator for android 11, you need to uninstall it and install the version for 13.
casualsnek/waydroid_script can do that for you. arm-translator for lineage 20 is currently not working correctly.