sodcalculator

10 Tech How-To

Build LineageOS on Windows 10: Step-by-Step

Guide 10-22275 · Updated · Step by step

This guide walks you through building LineageOS (a custom Android ROM) directly on a Windows 10 PC, without needing a separate Linux machine or virtual machine. You’ll use the Windows Subsystem for Linux (WSL) to run the required Linux build environment, then compile a flashable ZIP for your device. Before starting, you’ll need a decent PC (16GB RAM recommended, 200GB free disk space), a fast internet connection, and a supported device.

What You’ll Need

  • Windows 10 version 2004 or later (64-bit)
  • At least 16GB RAM (8GB minimum, but builds will be slow)
  • 200GB free disk space (SSD strongly recommended)
  • An unlocked bootloader on your target device
  • Basic familiarity with command line
  • Patience – first builds can take several hours

Step-by-Step

  1. Enable Windows Subsystem for Linux (WSL2)
    Open PowerShell as Administrator and run:
    wsl --install -d Ubuntu
    This installs WSL2 and Ubuntu. Restart your PC when prompted.
  2. Set up Ubuntu
    After restart, launch Ubuntu from the Start menu. Create a username and password when asked.
  3. Update Ubuntu packages
    In the Ubuntu terminal, run:
    sudo apt update && sudo apt upgrade -y
  4. Install required packages
    Run:
    sudo apt install git-core gnupg flex bison build-essential zip curl zlib1g-dev libc6-dev-i386 libncurses5 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev libxml2-utils xsltproc unzip fontconfig
  5. Install repo tool
    Run:
    mkdir -p ~/bin && curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo && chmod a+x ~/bin/repo
    Add ~/bin to your PATH by editing ~/.bashrc.
  6. Configure Git
    Run:
    git config --global user.name "Your Name"
    git config --global user.email "you@example.com"
  7. Initialize LineageOS source
    Create a directory and initialize the repo:
    mkdir ~/lineage && cd ~/lineage
    repo init -u https://github.com/LineageOS/android.git -b lineage-20.0
    (Replace lineage-20.0 with the latest branch for your device.)
  8. Sync the source code
    Run:
    repo sync -c -j8
    This downloads the entire Android source tree – it can take several hours. Use -j16 if you have a fast CPU and good internet.
  9. Prepare device-specific code
    For your specific device, you’ll need vendor blobs and device trees. The LineageOS wiki provides extraction scripts. Typically, you run:
    source build/envsetup.sh
    breakfast
    This downloads the necessary device configuration.
  10. Start the build
    Run:
    brunch
    The build will take 2-6 hours depending on your hardware. The output ZIP will be in out/target/product//.

Common Mistakes

  • Not enough disk space – The source tree alone is ~50GB, and the build adds another 50-100GB. Ensure you have 200GB free.
  • Running out of RAM – If the build crashes with OOM errors, reduce parallel jobs with -j4 or add swap space.
  • Wrong branch – Using an outdated branch can cause build failures. Always check the LineageOS wiki for your device’s supported branch.
  • Missing vendor blobs – Without proprietary drivers, the build will fail. Extract them from your device using the provided scripts.
  • Ignoring WSL version – WSL1 does not work well; ensure you’re on WSL2.

Tips

  • Use an SSD – building on a hard drive is painfully slow.
  • Close all other programs during the build to free up RAM.
  • Keep your Ubuntu installation up to date to avoid dependency issues.
  • If you run into errors, search the LineageOS subreddit or XDA forums – many issues are common and have fixes.
  • Consider using ccache to speed up subsequent builds: export USE_CCACHE=1 && ccache -M 50G.

Troubleshooting

If the build fails, read the error message carefully. Common issues include:

  • Missing packages – Re-run the package install command; you may have missed one.
  • Java version errors – LineageOS requires OpenJDK 11 for Android 11+; install it with sudo apt install openjdk-11-jdk.
  • Repo sync fails – Try repo sync -c -j4 to reduce network load, or run repo sync --force-sync.
  • Out of memory – Add a swap file: sudo fallocate -l 8G /swapfile && sudo chmod 600 /swapfile && sudo mkswap /swapfile && sudo swapon /swapfile.
  • WSL hangs – Restart WSL with wsl --shutdown in PowerShell, then relaunch Ubuntu.

Frequently Asked Questions

Can I build on Windows without WSL?

Officially, LineageOS only supports building on Linux. WSL2 is the recommended way on Windows; native Windows builds are not supported.

How long does the first build take?

On a modern 8-core CPU with 16GB RAM and an SSD, expect 2-4 hours. On slower hardware, it can take 8+ hours.

Do I need to unlock my device’s bootloader?

Yes, you must unlock the bootloader to flash the custom ROM. This process varies by device and may void your warranty.

Will building LineageOS brick my phone?

If you follow official instructions and use the correct build for your device, the risk is low. However, flashing any custom ROM carries some risk, so backup your data first.

Can I use a virtual machine instead of WSL?

Yes, but WSL2 is more efficient and integrates better with Windows. A VM will be slower due to overhead.

What if my device isn’t officially supported?

You can try building from community device trees, but you’ll need to find them on GitHub or XDA. Expect more troubleshooting.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →