Skip to content

Instantly share code, notes, and snippets.

@verNANDo57
Last active November 14, 2023 20:04
Show Gist options
  • Save verNANDo57/d76bb6e6e4b887101cf5a1cf64c66cef to your computer and use it in GitHub Desktop.
Save verNANDo57/d76bb6e6e4b887101cf5a1cf64c66cef to your computer and use it in GitHub Desktop.
Workarounds for building Android 11 on 8GB RAM
Workarounds for building R on 8GB RAM environment:
1. At the start of the build:
[ 99% 138/139] /mnt/ssd/lineage/out/soong/.bootstrap/bin/soong_build /mnt/ssd/lineage/out/soong/build.ninja
This used to take around 30mins, after enabling zram now it takes around 30secs (thanks to @kdrag0n for the zram idea) which is on par with what happens in 16GB RAM building environments
sudo apt install zram-config for installing zram-config package
sudo nano /etc/fstab and add a # in front of the swap disk if you have one and then reboot
After booting cat /proc/swaps to check if zram is enabled or not
2. To avoid issues while building metalava (outOfMemoryException: java heap space)
Pick this commit --> https://github.com/verNANDo57/android_build_soong/commit/5743f1ba9d95ff9c1f418066dcfdde9197c53a5a
3. To avoid huge metalava compilation times, compile the api-stubs-docs and other packages manually first then continue with mka bacon etc
For example this is what I'm using now in LineageOS:
. build/envsetup.sh && lunch lineage_joyeuse-userdebug & mka api-stubs-docs & mka module-lib-api-stubs-docs & mka system-api-stubs-docs & mka test-api-stubs-docs & mka bacon
Each of those api-stubs-docs, module-lib-api-stubs-docs etc took around 4-7 mins
Increasing of heap from soong directory or other env exports are not required
@iusmac
Copy link

iusmac commented Feb 3, 2022

@thongass000 your error is clear:

fatal error: unexpected signal during runtime execution
[signal SIGBUS: bus error code=0x2 addr=0xc0e2ed7080 pc=0x45d5b7]

This is a hardware error. Try again or inspect dmesg for more details.

@mitltl
Copy link

mitltl commented Feb 19, 2022

Newbie here, I am build lineage17.1 for some purposes. The second guide is invalid for 17.1(android10).
How can I deal with the third one, how to build them separately, lineage use
source build/envsetup.sh && breakfast my_device_codename && croot && brunch my_device_codename
Stucking with
//frameworks/base:api-stubs-docs Metalava [common]
etc.

@verNANDo57
Copy link
Author

@mitltl , Do:
source build/envsetup.sh && lunch your_device_codename && mka api-stubs-docs && mka hiddenapi-lists-docs && mka system-api-stubs-docs && mka test-api-stubs-docs && mka bacon

For example:
source build/envsetup.sh && lunch lineage_joyeuse-userdebug && mka api-stubs-docs && mka hiddenapi-lists-docs && mka system-api-stubs-docs && mka test-api-stubs-docs && mka bacon

This guide is for android 11 only. If you need guide for android 10, then check this

@Toug19
Copy link

Toug19 commented Jan 26, 2023

Swap partition is to be disabled in fstab, but what about swap file?

@seisdr
Copy link

seisdr commented Nov 14, 2023

soong.environment.used.build Android.bp fatal error: runtime: out of memory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment