[GUIDE] How to build LineageOS on Windows 10 (WSL 2.0)

Search This thread

M4Master96

Senior Member
Nov 21, 2017
150
58
43
Pune
www.teamos-hkrg.com
Building LineageOS 15.1 for oneplus2

hey @Uldiniad Thanks for this tutorial. I was facing "You are attempting to build with an unsupported JDK. Only an OpenJDK based JDK is supported". The issue was due to multiple java installations.

Executed:
Code:
$JAVA_HOME/bin/javac -version
Which showed that java was still pointing to oracle installation.

Ubuntu WSL was pointing JAVA_HOME to java-8-oracle even after making changes in /etc/environment and changing update-alternatives for java and javac.

As a solution, added
Code:
JAVA_HOME="/usr/lib/jvm/jdk1.8.0_212/"
in .profile and then executed 'source ~/.profile' and that solved the issue.
 
Last edited:

AT_21

Member
Aug 5, 2020
41
12
18
Please try to resolve my isssue

[email protected]:~/Project_Sakura/q$ lunch lineage_sakura-userdebug
17:15:52 Build sandboxing disabled due to nsjail error. This may become fatal in the future.
17:15:52 Please let us know why nsjail doesn't work in your environment at:
17:15:52
17:15:52
build/make/core/product_config.mk:228: error: device/xiaomi/sakura/lineage_sakura.mk does not exist
17:15:52 dumpvars failed with: exit status 1
Device sakura not found. Attempting to retrieve device repository from Sakura-Devices Github [
Repository for sakura not found in the Sakura-Devices Github repository list.
If this is in error, you may need to manually add it to your .repo/local_manifests/default.xml
17:15:59 Build sandboxing disabled due to nsjail error. This may become fatal in the future.
17:15:59 Please let us know why nsjail doesn't work in your environment at:
17:15:59
17:15:59
build/make/core/product_config.mk:228: error: device/xiaomi/sakura/lineage_sakura.mk does not exist
17:15:59 dumpvars failed with: exit status 1
17:16:04 Build sandboxing disabled due to nsjail error. This may become fatal in the future.
17:16:04 Please let us know why nsjail doesn't work in your environment at:
17:16:04
17:16:04
build/make/core/product_config.mk:228: error: device/xiaomi/sakura/lineage_sakura.mk does not exist
17:16:04 dumpvars failed with: exit status 1

** Don't have a product spec for: 'lineage_sakura'
** Do you have the right repo manifest?
I m getting this error while building
 

Uldiniad

Senior Member
Mar 17, 2016
343
266
0
[email protected]:~/Project_Sakura/q$ lunch lineage_sakura-userdebug
17:15:52 Build sandboxing disabled due to nsjail error. This may become fatal in the future.
17:15:52 Please let us know why nsjail doesn't work in your environment at:
17:15:52
17:15:52
build/make/core/product_config.mk:228: error: device/xiaomi/sakura/lineage_sakura.mk does not exist
17:15:52 dumpvars failed with: exit status 1
Device sakura not found. Attempting to retrieve device repository from Sakura-Devices Github [
Repository for sakura not found in the Sakura-Devices Github repository list.
If this is in error, you may need to manually add it to your .repo/local_manifests/default.xml
17:15:59 Build sandboxing disabled due to nsjail error. This may become fatal in the future.
17:15:59 Please let us know why nsjail doesn't work in your environment at:
17:15:59
17:15:59
build/make/core/product_config.mk:228: error: device/xiaomi/sakura/lineage_sakura.mk does not exist
17:15:59 dumpvars failed with: exit status 1
17:16:04 Build sandboxing disabled due to nsjail error. This may become fatal in the future.
17:16:04 Please let us know why nsjail doesn't work in your environment at:
17:16:04
17:16:04
build/make/core/product_config.mk:228: error: device/xiaomi/sakura/lineage_sakura.mk does not exist
17:16:04 dumpvars failed with: exit status 1

** Don't have a product spec for: 'lineage_sakura'
** Do you have the right repo manifest?
I m getting this error while building

is this in wsl 2.0? the setup seems odd. I do not recognize the device nor the source that it seems to be attempting to fetch. If you check soong and other logs in out/ dir you will probably find more details in there about what's happening.
 

AT_21

Member
Aug 5, 2020
41
12
18
Sorry

is this in wsl 2.0? the setup seems odd. I do not recognize the device nor the source that it seems to be attempting to fetch. If you check soong and other logs in out/ dir you will probably find more details in there about what's happening.

Yah I just noticed that I was using WSL 1.0 though I am using the latest build of Windows I'll try once again and let you know if any errors(btw what's soong). Thanks for help !
 
Last edited:

AT_21

Member
Aug 5, 2020
41
12
18
Restart Jack server

How can I restart Jack servers in wsl 2 as I am getting ran out of memory issues though I have the specified memory looks like the Ubuntu app is not using full RAM capacity.
 

Uldiniad

Senior Member
Mar 17, 2016
343
266
0
How can I restart Jack servers in wsl 2 as I am getting ran out of memory issues though I have the specified memory looks like the Ubuntu app is not using full RAM capacity.

vmmem is the process that you care about in wsl 2. concerning restarting jack servers check documentation, you'll find it on Google. I would not recommend compiling on less than 32GB of RAM
 

Axaroid

Member
Aug 4, 2019
8
0
1
I need some help, I followed the instructions to the T, however I receive this error:

MSI:~/android/lineage$ brunch enchilada
22:39:45 Build sandboxing disabled due to nsjail error. This may become fatal in the future.
22:39:45 Please let us know why nsjail doesn't work in your environment at:
22:39:45 https://groups.google.com/forum/#!forum/android-building
22:39:45 https://issuetracker.google.com/issues/new?component=381517
Looking for dependencies in device/oneplus/enchilada
Looking for dependencies in device/oneplus/sdm845-common
Looking for dependencies in kernel/oneplus/sdm845
kernel/oneplus/sdm845 has no additional dependencies.
Looking for dependencies in packages/resources/devicesettings
packages/resources/devicesettings has no additional dependencies.
22:39:52 Build sandboxing disabled due to nsjail error. This may become fatal in the future.
22:39:52 Please let us know why nsjail doesn't work in your environment at:
22:39:52 https://groups.google.com/forum/#!forum/android-building
22:39:52 https://issuetracker.google.com/issues/new?component=381517

============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=10
LINEAGE_VERSION=17.0-20190919-UNOFFICIAL-enchilada
TARGET_PRODUCT=lineage_enchilada
TARGET_BUILD_VARIANT=userdebug
TARGET_BUILD_TYPE=release
TARGET_ARCH=arm64
TARGET_ARCH_VARIANT=armv8-a
TARGET_CPU_VARIANT=generic
TARGET_2ND_ARCH=arm
TARGET_2ND_ARCH_VARIANT=armv8-a
TARGET_2ND_CPU_VARIANT=generic
HOST_ARCH=x86_64
HOST_2ND_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-4.4.0-18356-Microsoft-x86_64-Ubuntu-18.04.3-LTS
HOST_CROSS_OS=windows
HOST_CROSS_ARCH=x86
HOST_CROSS_2ND_ARCH=x86_64
HOST_BUILD_TYPE=release
BUILD_ID=QP1A.190711.020
OUT_DIR=out
PRODUCT_SOONG_NAMESPACES= device/oneplus/sdm845-common hardware/qcom/audio-caf/sdm845 hardware/qcom/display-caf/sdm845 hardware/qcom/media-caf/sdm845
============================================
22:40:40 Build sandboxing disabled due to nsjail error. This may become fatal in the future.
22:40:40 Please let us know why nsjail doesn't work in your environment at:
22:40:40 https://groups.google.com/forum/#!forum/android-building
22:40:40 https://issuetracker.google.com/issues/new?component=381517
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=10
LINEAGE_VERSION=17.0-20190919-UNOFFICIAL-enchilada
TARGET_PRODUCT=lineage_enchilada
TARGET_BUILD_VARIANT=userdebug
TARGET_BUILD_TYPE=release
TARGET_ARCH=arm64
TARGET_ARCH_VARIANT=armv8-a
TARGET_CPU_VARIANT=generic
TARGET_2ND_ARCH=arm
TARGET_2ND_ARCH_VARIANT=armv8-a
TARGET_2ND_CPU_VARIANT=generic
HOST_ARCH=x86_64
HOST_2ND_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-4.4.0-18356-Microsoft-x86_64-Ubuntu-18.04.3-LTS
HOST_CROSS_OS=windows
HOST_CROSS_ARCH=x86
HOST_CROSS_2ND_ARCH=x86_64
HOST_BUILD_TYPE=release
BUILD_ID=QP1A.190711.020
OUT_DIR=out
PRODUCT_SOONG_NAMESPACES= device/oneplus/sdm845-common hardware/qcom/audio-caf/sdm845 hardware/qcom/display-caf/sdm845 hardware/qcom/media-caf/sdm845
============================================
FAILED: ninja: ./build/blueprint/bootstrap/build.ninja:11: loading 'out/soong/.minibootstrap/build-globs.ninja': Exec format error
subninja ${myGlobs}
^ near here
22:40:42 soong minibootstrap failed with: exit status 1

#### failed to build some targets (48 seconds) ####


Any advice or ideas?
Same error for me if you fixed it then tell me the solution, it might be causing due to default microsoft linux kernel
 
T

Tenshi2112

Guest
Due to the limitations of WSL, the build will take a lot of time, but it successfully built the Custom ROM for my device.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 114
    Requirements
    https://source.android.com/setup/build/requirements#hardware-requirements
    https://docs.microsoft.com/en-us/windows/wsl/install-win10#install-the-windows-subsystem-for-linux
    https://docs.microsoft.com/en-us/windows/wsl/install-win10#update-to-wsl-2

    You may want to expand the default virtual disk size:
    https://docs.microsoft.com/en-us/wi...-the-size-of-your-wsl-2-virtual-hardware-disk

    Setting up a Windows Subsystem for Linux (WSL 2.0) build environment
    1. Open Microsoft Store
    2. Search for and install the Ubuntu app
    3. Open the app and follow the first-time setup steps
    4. Update packages and install the following (if building lineage-17.1, please refer to their documentation for other versions):
      Code:
      sudo apt update && sudo apt full-upgrade -y && sudo apt install -y build-essential ccache libncurses5 libssl-dev m4 unzip zip
    5. Make a directory for the source code (and go to it):
      Code:
      mkdir -p ~/android/lineage && cd android/lineage
    6. Initialize the LineageOS source repository:
      Code:
      repo init -u https://github.com/LineageOS/android.git -b lineage-17.1
    7. Sync the sources:
      Code:
      repo sync
    8. (Optional; Recommended) https://wiki.lineageos.org/devices/klte/build#turn-on-caching-to-speed-up-build
    9. Run
      Code:
      source build/envsetup.sh
    10. Prepare the device-specific code:
      Code:
      breakfast [I]your device codename[/I]
    11. Add the following to .repo/local_manifests/roomservice.xml:
      Code:
      <project name="TheMuppets/proprietary_vendor_[I]your device brand[/I]" path="vendor/[I]your device brand[/I]" remote="github" />
    12. Sync the sources again:
      Code:
      repo sync
    13. Start the build:
      Code:
      brunch [I]your device codename[/I]

    For future builds, you need to repeat steps 13 -> 10 -> 14 at the root of the tree
    21
    Useful resources

    Running a Desktop Environment
    https://github.com/microsoft/WSL/issues/4106#issuecomment-636446405

    Using mnt (consider performance https://github.com/microsoft/WSL/issues/4197):
    1. Create /etc/wsl.conf
    2. Add
    Code:
    [automount] options = "metadata"
    3. Run
    Code:
    wsl --shutdown
    from PowerShell
    After restarting wsl, make sure
    Code:
    mount -l | grep metadata
    shows your drvfs mounts with the metadata tag added.

    WSL2 install location: https://github.com/MicrosoftDocs/WSL/issues/412#issuecomment-575923176
    12
    WSL 2.0 is OUT, build all the droids!

    Hi all,

    Microsoft just released the Windows 10 May 2020 update. But the bigger news is that it comes with WSL2. The TLDR of it is that Windows now has a Linux kernel bundled with it and that's game changing. And what that means for us is out of the box / seamless linux-like functionality for all teh things (goodbye Lineage hax patches for WSL1).

    I have updated OP https://forum.xda-developers.com/showpost.php?p=75579631&postcount=1 and the useful resources post https://forum.xda-developers.com/showpost.php?p=75579631&postcount=2 with the latest information I have so far. Note that with wsl2 using mnt is a readily available option and the wsl installation location can easily be changed as well :) Lots more flexibility

    Lastly, wanted to say thanks to all for your patience. I started this project while I was in the middle of university. I did this "for fun" with the goal of seeing if compiling Android on Windows (via WSL) would be remotely possible and if I personally would be able to pull that off. Apparently, I did :p. Part of this work (added with other work I did with Lineage) allowed me to get the Android job I currently have and I'm grateful for it.
    I know WSL 1 was a bit of a pain to work with and that headaches and frustration came from it. The good news, is those days are over. And the future is now.

    If you have questions that are not answered already in other posts, send them through. I will be randomly checking the thread. Although given that wsl2 doesn't need anywhere near as much maintenance as wsl1 I will probably be more hands off than I used to be (e.g. update the docs for newer versions of Android or Windows, etc.).

    Take care,
    Uldiniad
    11
    Pie (wsl flavour) is out of the oven

    Hey everyone,

    TL;DR
    It is now possible to build lineage-16.0 on wsl! Just follow the updated guide from start to finish (syncing 16.0 on top of 15.1 is not recommended) and enjoy.
    DO NOT COMPLAIN ABOUT ANY ERRORS THAT ARE NOT STRICTLY DUE TO THE BUILD ENVIRONMENT (WSL). Many devices are not ready to build yet!

    Also, as always, I recommend building on the latest version of Windows. October Update was released recently: https://www.microsoft.com/en-ca/software-download/windows10

    For those still insterested in building 15.1 (ignore the repopick step): https://web.archive.org/web/2018061...ng/guide-how-to-build-lineageos-15-1-t3750175 (as mentioned in my previous announcement, do not report any errors, I will ignore them, since I do not have the means to maintain more than one branch on wsl)

    Full version:
    It has been some time since the last update. I apologise for the crickets.
    I didn't want to write a post until I was able to guarantee I could build lineage-16.0 without issues on wsl. I downloaded the sources as soon as they were released but was unable to complete a full build for my device without cherry-picking lots of patches for it and decided against it since I wanted to reduce the scope of the errors to the build environment alone. I only recently thought of building a generic image instead (which would accomplish what I wanted). Thankfully, wsl had less problems this time cause Google were cool with updating their bison and flex prebuilts (thereby now making them 64-bit) and killed off ijar (hopefully forever). So only dex2oat needed a patch this time around :D
    The wsl-compile-lineage-16.0 patches are merged (https://review.lineageos.org/#/q/st...h:lineage-16.0+topic:wsl-compile-lineage-16.0). So no additional steps required there. Otherwise, make sure to install m4 since it spat out an error about it missing.

    Thank you for your support,

    Uldiniad

    P.S. Feel free to ask any questions related to this and check my previous announcements to know my goals and standards for this side-project (https://forum.xda-developers.com/showpost.php?p=77321912&postcount=261 for example)
    P.P.S. I am working on making an official wiki page on the LineageOS website which will be more convenient than this thread. I might consider leaving the thread open for feedback once it is open, but I might also consider having feedback reported via official means (JIRA probably).
    6
    Want a piece of Pie?

    Hey everyone, got some news to share.

    As you may have heard, the Pie is now out of the oven. Given that,
    1. At the moment building android on WSL is 100% experimental
    2. There seems to be little to no interest from Google and Microsoft to officially support wsl as an android build environment
    3. I'm working alone with limited time and knowledge of both the android build environment and the inner workings of wsl
    4. I plan on supporting the latest version of lineage available
    I am therefore starting research and work on lineage-16.0 and will be leaving lineage-15.1 as it currently stands.
    As windows updates come, wsl will change and may bring new unforeseen errors to the oreo build environment. Since I will not be maintaing that branch anymore, it may mean that the best option to keep building 15.1 is to not update to the latest build of windows if it causes errors. Given this situation I will be paying less attention to bug reports for 15.1 as time goes by and 16.x takes its place (especially since I do not have 15.1 synced anymore and will not be able to reproduce errors).

    For 16.x, it entails I will proceed to ram my head into the wsl wall until it gives up or I do.

    Hoping we'll all get a piece of the Pie,

    Uldiniad
Our Apps
Get our official app!
The best way to access XDA on your phone
Nav Gestures
Add swipe gestures to any Android
One Handed Mode
Eases uses one hand with your phone