Building Android on Windows

These instructions will help you to build LineageOS 15.1 for the Samsung Galaxy S9+ (Exynos variant, code name “star2lte”) on a Windows 10 PC.

Building LineageOS requires Windows Subsystem for Linux. Open start menu and type “Turn Windows features on or off”, scroll down to tick “Windows Subsystem for Linux”. After rebooting (if necessary) open the Windows Store app and install Ubuntu. On first run, Ubuntu will ask you to set a username and password for the Linux environment. Next run these commands to update your Linux packages.

sudo apt update
sudo apt upgrade -y
sudo apt autoremove -y

Use the nano text editor to add these lines to the end of your bashrc file.

nano .bashrc

Scroll down to the bottom of the file then copy these lines and paste them in by right-clicking the Linux console window.

export LC_ALL=C
export BISON_EXEC=~/android/lineage/out/host/linux-x86/bin/bison
export IJAR_EXEC=~/android/lineage/out/host/linux-x86/bin/ijar
export ANDROID_JACK_VM_ARGS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4G"

Save and exit nano with ctrl+x, y. Now reload that file to apply the changes.

source .bashrc

Download and extract the Android platform tools and repo.

unzip -d ~

sudo apt install curl
mkdir ~/bin
curl > ~/bin/repo
chmod a+x ~/bin/repo

Edit your profile file.

nano .profile

And add these lines at the end:

# add Android SDK platform tools to path
if [ -d "$HOME/platform-tools" ] ; then

Save changes and reload to apply.

source .profile

Install the Linux packages required to build Android.

sudo apt install bc build-essential ccache curl flex g++-multilib gcc-multilib git gnupg gperf imagemagick lib32ncurses5-dev lib32readline-dev lib32z1-dev liblz4-tool libncurses5-dev libsdl1.2-dev libssl-dev libwxgtk3.0-dev libxml2 libxml2-utils lzop pngcrush rsync schedtool squashfs-tools xsltproc zip zlib1g-dev python openjdk-8-jdk repo -y

Create the directories.

mkdir -p ~/android/lineage

Initialise the git repository that will contain the LineageOS source code.

cd ~/android/lineage
git config --global "[email protected]"
git config --global "Your Name"
repo init -u -b lineage-15.1

Edit this file and add the following line to add proprietary hardware drivers to your build. Edit the details to match your phone.

mkdir -p .repo/local_manifests
nano .repo/local_manifests/roomservice.xml

<project name="TheMuppets/proprietary_vendor_samsung" path="universal9810-common" remote="github" />

Instead of using TheMuppets repository in the last step, you could try extracting the proprietary files from an existing LineageOS zip, or use ADB to extract them from your phone. Both of those methods were missing one important file that is necessary for mobile data to work on my device.

Download the Android and LineageOS source code.

repo sync

Download the specific configuration and kernel for my phone.

source build/
breakfast star2lte

This part is optional. Edit the file in Android source code to force your device to always use your preferred DNS server.

nano frameworks/opt/telephony/src/java/com/android/internal/telephony/dataconnection/

Press ctrl+w to search for “set dns servers” then comment out that section of code by typing /* at the start and */ at the end. Underneath it, add this line to use CloudFlare’s public DNS server:


Build bison and ijar to fix a bug in WSL. On a real Linux system this is not necessary.

make bison && make ijar

And finally build the LineageOS image.

brunch star2lte

Move the completed package to your Windows Documents folder so it can be flashed to the phone with ADB.

cd $OUT
mv lineage-15.1-* /mnt/c/Users/Username/Documents/

To build another image with updated sources (e.g. after each monthly Android security bulletin), you only need to run these commands next time:

cd ~/android/lineage
repo sync --force-sync
source build/
breakfast star2lte
brunch star2lte