You need at least 250 GB free space, SSD is strongly recommended. If free space is low, BTRFS can be used for transparent compression.
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-18.1 cd lineage-18.1 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-18.1 --git-lfs repo sync build/make
-
Get waydroid vendor manifest
wget -O - https://raw.githubusercontent.com/waydroid/android_vendor_waydroid/lineage-18.1/manifest_scripts/generate-manifest.sh | bash
-
OpenGapps 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="opengapps" fetch="https://github.com/opengapps/" /> <remote name="opengapps-gitlab" fetch="https://gitlab.opengapps.org/opengapps/" /> <project path="vendor/opengapps/build" name="aosp_build" revision="master" remote="opengapps" /> <project path="vendor/opengapps/sources/all" name="all" clone-depth="1" revision="master" remote="opengapps-gitlab" /> <project path="vendor/opengapps/sources/x86_64" name="x86_64" clone-depth="1" revision="master" remote="opengapps-gitlab" />
For arm add this instead of x86_64
<!-- arm64 depends on arm --> <project path="vendor/opengapps/sources/arm" name="arm" clone-depth="1" revision="master" remote="opengapps-gitlab" /> <project path="vendor/opengapps/sources/arm64" name="arm64" clone-depth="1" revision="master" remote="opengapps-gitlab" />
-
Sync repos
About 130 gigabytes of data will be downloaded
repo sync
-
OpenGapps 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
# GAPPS GAPPS_VARIANT := pico $(call inherit-product, vendor/opengapps/build/opengapps-packages.mk)
or
curl https://raw.githubusercontent.com/YogSottot/waydroid_stuff/master/kernel_build/lineage-18.1/0001-Add-opengapps-in-device.mk.patch | git -C device/waydroid/waydroid/ apply -v --index
curl https://github.com/cwhuang/aosp_build/commit/384cdac7930e7a2b67fd287cfae943fdaf7e5ca3.patch | git -C vendor/opengapps/build apply -v --index curl https://github.com/cwhuang/aosp_build/commit/3bb6f0804fe5d516b6b0bc68d8a45a2e57f147d5.patch | git -C vendor/opengapps/build apply -v --index
-
Apply waydroid patches
. build/envsetup.sh apply-waydroid-patches
-
Apply custom patches
If you don't need the patches, why are you building images? You can get official images via
waydroid init -f -s GAPPS
.-
Enable squashfs images [PR]
curl https://patch-diff.githubusercontent.com/raw/waydroid/android_device_waydroid_waydroid/pull/2.patch | git -C device/waydroid/waydroid/ apply -v --index
-
Only x86_64: BoardConfig: Reland scudo native allocator for x86 devices [PR]
sed -i 's/MALLOC_SVELTE\ \:\=\ true//g' device/waydroid/waydroid/BoardConfig.mk # apply patch doesn't work because of the above patch # curl https://patch-diff.githubusercontent.com/raw/waydroid/android_device_waydroid_waydroid/pull/4.patch | git -C device/waydroid/waydroid/ apply -v --index
-
Add force_mouse_as_touch option. PR
If PR is already merged, this patch is no longer neededcurl https://raw.githubusercontent.com/waydroid/android_vendor_waydroid/828afefb59ccce46e089756e95e15e6191e272f1/waydroid-patches/base-patches-30/frameworks/base/0051-Force-mouse-event-as-touch-1-2.patch | git -C frameworks/base/ apply -v --index curl https://raw.githubusercontent.com/waydroid/android_vendor_waydroid/828afefb59ccce46e089756e95e15e6191e272f1/waydroid-patches/base-patches-30/frameworks/native/0015-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-18.1/0001-patch-30-Enable-xmlconfig-on-Android-01.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 image
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, create a volume for it
mkdir -p /mnt/ccache/lineage-18.1 docker create -v /mnt/ccache/lineage-18.1:/ccache --name ccache-18.1 waydroid-build-24.04
-
Build system images
docker run -e CCACHE_DIR=/ccache --volumes-from ccache-18.1 -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-18.1 -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:
../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
-
If you get the error:
java.lanjava.lang.OutOfMemoryError: Java heap spaceg.OutOfMemoryError: Java heap space
then do this:- Open file
build/soong/java/droiddocdoc.go
- Go to line 1476
- Add a new line with content
Flag("-JXmx10g").
- This is how that part should look like:
cmd.BuiltTool(ctx, "metalava"). Flag(config.JavacVmFlags). Flag("-JXmx10g"). FlagWithArg("-encoding ", "UTF-8"). FlagWithArg("-source ", javaVersion.String()). FlagWithRspFileInputList("@", srcs). FlagWithInput("@", srcJarList)
- Open file
Also you can create both images with a single command:
docker run -e CCACHE_DIR=/ccache --volumes-from ccache-18.1 -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 beforehand
rsync -a /var/lib/waydroid /opt/waydroid_backups/
Your images are in current dir [lineage-18.1] (system.img / vendor.img) You can use rsync to copy images to /var/lib/waydroid/images
rsync *.img /var/lib/waydroid/images/