DEV Community

Alex Antsiferov
Alex Antsiferov

Posted on • Updated on

Building LineageOS in WSL2

A few days ago, I needed an Android phone for some experiments, so I fished out an old Nexus 5 "Hammerhead" from a drawer where I keep the assorted lengths of wires.

However, it had a pretty outdated Android 6 OS, and some apps refused to install. So I decided to get it a slightly newer LineageOS 14.1 (based on Android 7). Feeling adventurous, I decided to build one myself instead of downloading a ready build (from god-knows-where, by the way).

I used this guide.
Overall, it was surprisingly comprehensive. Still, I encountered a few obstacles, writing them down here for reference.

Notable hiccups

Preparing tools

Getting the source files in place

  • I'm using zsh, and it doesn't normally execute .profile, so my $HOME/bin wasn't included in the path -- repo didn't run. I got lazy and just dropped it in the sources folder, and was punished on one of the next steps: failure to execute repo was breaking the breakfast pipeline. Luckily, the error was logged.
  • Proprietary blobs for the device: this seemed like a Catch-22 situation; then I realised that I could get those from TheMuppets (https://github.com/TheMuppets/proprietary_vendor_lge/tree/cm-14.1); note the branch in the path.
  • TheMuppets repo must be included in the .repo/local_manifests/roomservice.xml like this:
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
  <project name="LineageOS/android_device_lge_hammerhead" path="device/lge/hammerhead" remote="github" />
  <project name="LineageOS/android_kernel_lge_hammerhead" path="kernel/lge/hammerhead" remote="github" />
  <project name="TheMuppets/proprietary_vendor_lge" path="vendor/lge" remote="github" revision="cm-14.1" />
</manifest>
Enter fullscreen mode Exit fullscreen mode
  • After rerunning repo sync the blobs were added to the source files.

Building

  • The build process was inexplicably failing somewhere around 2%. I ran jack-diagnose tool from prebuilts/sdk/tools, but it wasn't detecting any issues. Neither the jack-server logs had anything of note in them.
  • I suspected that jack-server was quietly crashing due to insufficient memory, and did several things at once:
    • increased WSL memory limit from 6Gb to 8Gb (my laptop has 16Gb total),
    • in ~/.jack-server/config.properties, set jack.server.max-service to 1 instead of 4,
    • set -Xmx5G instead of -Xmx4G in ANDROID_JACK_VM_ARGS,
    • and upgraded jack-server package as suggested here.

Not sure which exact part was crucial, but after doing this the build went on smoothly.

Loading the firmware

  • The TWRP recovery wouldn't start from the bootloader, so I had to use this command: fastboot boot <recovery.img> instead.
  • I had to install the "pico" (smallest) Google Apps package along the OS ROM, otherwise it wouldn't fit in without repartitioning.

Finally

The first boot of LineageOS took a while, and I had to reboot it once when it got stuck at "looking for updates" step.
After the initial setup, it has been working pretty well! On with the experiments!

Discussion (0)