[GUIDE] How to build Android on Windows

Search This thread

Uldiniad

Senior Member
Mar 17, 2016
346
269
Useful resources




https://github.com/MicrosoftDocs/WSL/issues/412#issuecomment-575923176
 
Last edited:

1a2a3a4aq

Member
Feb 11, 2018
7
2
Hello, Thanks for your great guide. I was able to finish the build nearly successfully.

USE_HOST_BISON is opt-in, so you don't need to set it false unless you've exported USE_HOST_BISON=true before.

I've seen the change 196115, but is this change really needed for WSL build?
It seems like change for non-WSL build. (whose don't need to use prebuilt FLEX)
 
Last edited:
  • Like
Reactions: Vmb265 and Uldiniad

Uldiniad

Senior Member
Mar 17, 2016
346
269
Hello, Thanks for your great guide. I was able to finish the build nearly successfully.

USE_HOST_BISON is opt-in, so you don't need to set it false unless you've exported USE_HOST_BISON=true before.

I've seen the change 196115, but is this change really needed for WSL build?
It seems like change for non-WSL build. (whose don't need to use prebuilt FLEX)

Thanks for your feedback.
As you pointed out, I made a mistake in the number of the commit to be cherrypicked. I've corrected the OP, so, the command should now work and you can also see the code that is added by the commit by following the link. Thanks for pointing that out.
WSL only supports 64-bit binaries. That is why I've left out bison and flex from the packages to be installed for the build environment and instead have put the code to my forked repos which have prebuilt 64-bit bison and flex. Then I've set USE_HOST_BISON and USE_HOST_FLEX to false in bashrc so that it doesn't go looking for the packages that would typically be installed with apt-get and makes sure the 64-bit prebuilts are used (but as you said, it might be an unnecessary precaution but it doesn't hurt to have it).

Hope that helps. And if you have more questions, ask away.
 
Last edited:

1a2a3a4aq

Member
Feb 11, 2018
7
2
Thanks for your feedback.
As you pointed out, I made a mistake in the number of the commit to be cherrypicked. I've corrected the OP, so, the command should now work and you can also see the code that is added by the commit by following the link. Thanks for pointing that out.
WSL only supports 64-bit binaries. That is why I've left out bison and flex from the packages to be installed for the build environment and instead have put the code to my forked repos which have prebuilt 64-bit bison and flex. Then I've set USE_HOST_BISON and USE_HOST_FLEX to false in bashrc so that it doesn't go looking for the packages that would typically be installed with apt-get and makes sure the 64-bit prebuilts are used (but as you said, it might be an unnecessary precaution but it doesn't hurt to have it).

Hope that helps. And if you have more questions, ask away.

btw, using "/bin/bash -c" instead of brunch does not make effect for me.
build stucks while doing dex2oat jobs just like using brunch.
build with WITH_DEXPREOPT=false was successful, but 8.1 must use dexpreopt due to sepolicy changes. still searching on this.
 

Uldiniad

Senior Member
Mar 17, 2016
346
269
btw, using "/bin/bash -c" instead of brunch does not make effect for me.
build stucks while doing dex2oat jobs just like using brunch.
build with WITH_DEXPREOPT=false was successful, but 8.1 must use dexpreopt due to sepolicy changes. still searching on this.

Ok, thanks for mentioning this. I had success with the /bin/bash -c command but if this is not universal, then, as you said, we should find another universal workaround or fix and I'll replace mine with it in the OP. I'll look into WITH_DEXPREOPT and other possibilities on my end too.
I've reopened the issue on GitHub while there is no universal fix or workaround: https://github.com/Microsoft/WSL/issues/2948
 
  • Like
Reactions: WinterR

Uldiniad

Senior Member
Mar 17, 2016
346
269
btw, using "/bin/bash -c" instead of brunch does not make effect for me.
build stucks while doing dex2oat jobs just like using brunch.
build with WITH_DEXPREOPT=false was successful, but 8.1 must use dexpreopt due to sepolicy changes. still searching on this.

I've opened this page: https://source.android.com/devices/tech/dalvik/configure
I'm thinking of trying out different makefile options instead of disabling dex2oat altogether and see if it makes a difference for the brunch command. Maybe you can do the same and keep us posted
 
  • Like
Reactions: WinterR

Uldiniad

Senior Member
Mar 17, 2016
346
269
Thanks for posting the tutorial
@Uldiniad
I'm very thankful to you for this.
One question, is it possible to download the whole source somewhere else so that we don't have to download the complete source across windows formats and system restores?

As far as I know, at this point in time it is not (that's why I put up the requirements and warnings on the OP). WSL is made to work mostly within its own environment (somewhat separate from Windows) and intercompatibility/interoperability with the Windows file system is limited. Linux and Windows don't have the same file management systems (which is why manipulating files of the subsystem from Windows Explorer and the mount option are out the window for now). Also, there is no simple way of changing the installation location of lxss as of today (although, you can check WSL's GitHub if you're really determined to move it ;)).
WSL is picky and that is why threads like this exist. If WSL worked like Ubuntu out of the box this thread wouldn't be necessary (LineageOS' guide would suffice).
 
G

GuestK00254

Guest
Yep. I'm currently running a build on my s5 that I made myself on the Ubuntu app for Windows 10. We are currently working on fixing the dex2oat issues but other users have suggested workarounds in the mean time.

ok thanks bro. New to rom building, but I did build a DU rom that works for sailfish
 

taxueliuyun

Member
Mar 4, 2018
6
2
Hello Uldiniad, thanks your guide. I got a error, When I start the build "brunch gemini":
[1055/1074] including ./vendor/qcom/opensource/cryptfs_hw/Android.mk ...
build/core/binary.mk:40: warning: libcryptfs_hw uses deprecated kernel header dependency path.
[1056/1074] including ./vendor/qcom/opensource/dataservices/Android.mk ...
build/core/binary.mk:40: warning: librmnetctl uses deprecated kernel header dependency path.
build/core/binary.mk:40: warning: sockev uses deprecated kernel header dependency path.
[1074/1074] including ./vendor/xiaomi/scorpio/Android.mk ...
waitpid failed: No child processes
19:40:52 ckati failed with: exit status 1
I have no idea, please help me, thanks. ( I run windows 10 in virtualbox)
 

Uldiniad

Senior Member
Mar 17, 2016
346
269
Hello Uldiniad, thanks your guide. I got a error, When I start the build "brunch gemini":
[1055/1074] including ./vendor/qcom/opensource/cryptfs_hw/Android.mk ...
build/core/binary.mk:40: warning: libcryptfs_hw uses deprecated kernel header dependency path.
[1056/1074] including ./vendor/qcom/opensource/dataservices/Android.mk ...
build/core/binary.mk:40: warning: librmnetctl uses deprecated kernel header dependency path.
build/core/binary.mk:40: warning: sockev uses deprecated kernel header dependency path.
[1074/1074] including ./vendor/xiaomi/scorpio/Android.mk ...
waitpid failed: No child processes
19:40:52 ckati failed with: exit status 1
I have no idea, please help me, thanks. ( I run windows 10 in virtualbox)

would you mind running
Code:
breakfast gemini && make bacon showcommands
just based off the snippet you gave above I can't say much about the failure, the "no child processes" failure could be because it is not finding the next tasks (possibly missing some makefiles) to be executed for some reason (which would be strange).
also, are you successfully building on other platforms? and did you follow the OP step-by-step?
note: it shouldn't matter, but I recommend running windows natively if you want to build on lxss. but on vm it shouldn't matter (that I know of). although if you're running windows in a virtual machine, what are you running natively? probably a unix-based system right? because if so, darwin or linux will have more chances of successful builds than wsl guaranteed
 
Last edited:
Oct 7, 2017
8
0
hello Uldiniad getting error while building for my kenzo

11. mini_emulator_arm64-userdebug
12. m_e_arm-userdebug
13. mini_emulator_x86_64-userdebug
14. mini_emulator_x86-userdebug
15. uml-userdebug
16. aosp_kenzo-userdebug
17. aosp_kenzo-user
18. aosp_kenzo-eng
19. lineage_angler-userdebug
20. lineage_bullhead-userdebug
21. lineage_capricorn-userdebug
22. lineage_cheeseburger-userdebug
23. lineage_dumpling-userdebug
24. lineage_gemini-userdebug
25. lineage_gts210vewifi-userdebug
26. lineage_gts28vewifi-userdebug
27. lineage_natrium-userdebug
28. lineage_oneplus3-userdebug
29. lineage_zl1-userdebug
Which would you like? [aosp_arm-eng] 16
build/core/product_config.mk:237: *** Can not locate config makefile for product "aosp_kenzo". Stop.
Device kenzo not found. Attempting to retrieve device repository from LineageOS Github (githubcom/LineageOS
).
Found repository: android_device_xiaomi_kenzo
Default revision: lineage-15.1
Checking branch info
Default revision lineage-15.1 not found in android_device_xiaomi_kenzo. Bailing.
Branches found:
cm-13.0
cm-14.
cm-14.1
lineage-15.0
stable/cm-13.0-ZNH5Y
Use the ROOMSERVICE_BRANCHES environment variable to specify a list of fallback branches.
build/core/product_config.mk:237: *** Can not locate config makefile for product "aosp_kenzo". Stop.
build/core/product_config.mk:237: *** Can not locate config makefile for product "aosp_kenzo". Stop.
** Don't have a product spec for: 'aosp_kenzo'
** Do you have the right repo manifest?
jain2vicky@instance-2:~/los151$
 

taxueliuyun

Member
Mar 4, 2018
6
2
would you mind running
Code:
breakfast gemini && make bacon showcommands
just based off the snippet you gave above I can't say much about the failure, the "no child processes" failure could be because it is not finding the next tasks (possibly missing some makefiles) to be executed for some reason (which would be strange).
also, are you successfully building on other platforms? and did you follow the OP step-by-step?
note: it shouldn't matter, but I recommend running windows natively if you want to build on lxss. but on vm it shouldn't matter (that I know of). although if you're running windows in a virtual machine, what are you running natively? probably a unix-based system right? because if so, darwin or linux will have more chances of successful builds than wsl guaranteed

thanks for your reply, my host os is macos, I can compile aosp successfully in my macpro, or ubuntu in my virtualbox, by follow the official guide. But I want to build aosp in wsl for my purpose, so I found your guide. I followed the OP step by step, no error happened until the last step. Just a few warnings and interrupted many times when I called " repo sync", the error message is below:
Shared project LineageOS/android_hardware_qcom_wlan found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_wlan found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_display found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_display found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_display found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_display found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_display found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_display found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_display found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_display found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_display found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_media found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_media found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_media found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_media found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_media found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_media found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_media found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_media found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_media found, disabling pruning.
Shared project LineageOS/android_hardware_ril found, disabling pruning.
Shared project LineageOS/android_hardware_ril found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_audio found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_audio found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_audio found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_audio found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_audio found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_audio found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_audio found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_audio found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_audio found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_bt found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_bt found, disabling pruning.

I called "make gemini showcommands" just now, the terminal prints some command procedures, but it does not help, it's still the same error.
 

Uldiniad

Senior Member
Mar 17, 2016
346
269
11. mini_emulator_arm64-userdebug
12. m_e_arm-userdebug
13. mini_emulator_x86_64-userdebug
14. mini_emulator_x86-userdebug
15. uml-userdebug
16. aosp_kenzo-userdebug
17. aosp_kenzo-user
18. aosp_kenzo-eng
19. lineage_angler-userdebug
20. lineage_bullhead-userdebug
21. lineage_capricorn-userdebug
22. lineage_cheeseburger-userdebug
23. lineage_dumpling-userdebug
24. lineage_gemini-userdebug
25. lineage_gts210vewifi-userdebug
26. lineage_gts28vewifi-userdebug
27. lineage_natrium-userdebug
28. lineage_oneplus3-userdebug
29. lineage_zl1-userdebug
Which would you like? [aosp_arm-eng] 16
build/core/product_config.mk:237: *** Can not locate config makefile for product "aosp_kenzo". Stop.
Device kenzo not found. Attempting to retrieve device repository from LineageOS Github (githubcom/LineageOS
).
Found repository: android_device_xiaomi_kenzo
Default revision: lineage-15.1
Checking branch info
Default revision lineage-15.1 not found in android_device_xiaomi_kenzo. Bailing.
Branches found:
cm-13.0
cm-14.
cm-14.1
lineage-15.0
stable/cm-13.0-ZNH5Y
Use the ROOMSERVICE_BRANCHES environment variable to specify a list of fallback branches.
build/core/product_config.mk:237: *** Can not locate config makefile for product "aosp_kenzo". Stop.
build/core/product_config.mk:237: *** Can not locate config makefile for product "aosp_kenzo". Stop.
** Don't have a product spec for: 'aosp_kenzo'
** Do you have the right repo manifest?
jain2vicky@instance-2:~/los151$

Your device does not have lineage-15.1 yet. check the branches here: https://github.com/LineageOS/android_device_xiaomi_kenzo
 

Uldiniad

Senior Member
Mar 17, 2016
346
269
thanks for your reply, my host os is macos, I can compile aosp successfully in my macpro, or ubuntu in my virtualbox, by follow the official guide. But I want to build aosp in wsl for my purpose, so I found your guide. I followed the OP step by step, no error happened until the last step. Just a few warnings and interrupted many times when I called " repo sync", the error message is below:
Shared project LineageOS/android_hardware_qcom_wlan found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_wlan found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_display found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_display found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_display found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_display found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_display found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_display found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_display found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_display found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_display found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_media found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_media found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_media found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_media found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_media found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_media found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_media found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_media found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_media found, disabling pruning.
Shared project LineageOS/android_hardware_ril found, disabling pruning.
Shared project LineageOS/android_hardware_ril found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_audio found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_audio found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_audio found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_audio found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_audio found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_audio found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_audio found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_audio found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_audio found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_bt found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_bt found, disabling pruning.

I called "make gemini showcommands" just now, the terminal prints some command procedures, but it does not help, it's still the same error.

the pruning is not an error. it is saying that the project is shared (used by other devices potentially) and therefore it does not apply pruning to the tree.
the reason I wanted you to post the showcommands is so that I can see what is the last few commands before the error
 

Top Liked Posts

  • There are no posts matching your filters.
  • 21
    Useful resources




    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://xdaforums.com/showpost.php?p=75579631&postcount=1 and the useful resources post https://xdaforums.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://xdaforums.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