Skip to content

Instantly share code, notes, and snippets.

@verNANDo57
Created March 18, 2022 06:53
Show Gist options
  • Save verNANDo57/9c14d529d91e79f3b42fa6bd7b9eba85 to your computer and use it in GitHub Desktop.
Save verNANDo57/9c14d529d91e79f3b42fa6bd7b9eba85 to your computer and use it in GitHub Desktop.
Workarounds for building Android 12 on 8GB RAM
Workarounds for building S 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/ffc8846a01fcfc20d6cf8ca701ef73d99f15acad
@OGDR
Copy link

OGDR commented Oct 9, 2022

Im at the file. Am i adding code.

@KingProNoob2
Copy link

Yes, go here verNANDo57/android_build_soong@ffc8846, copy the contents of the file in the link. Also, are you using a gui or just cli?

@OGDR
Copy link

OGDR commented Oct 9, 2022

Yes, go here verNANDo57/android_build_soong@ffc8846, copy the contents of the file in the link. Also, are you using a gui or just cli?

Window manager simular to i3 but built for mouse and has some functions simular to desktop. Distro arch linux.

@OGDR
Copy link

OGDR commented Oct 9, 2022

I know how to use the command line. So no problem. But i also have vim and a light weight gui text editor.

@OGDR
Copy link

OGDR commented Oct 9, 2022

Also where exaxtly are the xontents being pasted to. In which spot.

@KingProNoob2
Copy link

So, search the file for cmd.BuildTool, and replace it and some lines after it with the edited version.

@OGDR
Copy link

OGDR commented Oct 9, 2022

So, search the file for cmd.BuildTool, and replace it and some lines after it with the edited version.

in the file from the link or my file

@OGDR
Copy link

OGDR commented Oct 9, 2022

So, search the file for cmd.BuildTool, and replace it and some lines after it with the edited version.

I found the cmd.buildtool. Where do I stop pasting at.

@OGDR
Copy link

OGDR commented Oct 9, 2022

So, search the file for cmd.BuildTool, and replace it and some lines after it with the edited version.

I see where the metalava stops but do you think I should add the lint lines to?

@KingProNoob2
Copy link

Add Flag("-J-Xmx6114m") under Flag(config.JavacVmFlags)

@OGDR
Copy link

OGDR commented Oct 9, 2022

Add Flag("-J-Xmx6114m") under Flag(config.JavacVmFlags)

Its already there

@KingProNoob2
Copy link

All right, so just try to build it and see (I think the error from before is because the modified version mentioned in the post is based on lineage os and it is different from aosp.

@OGDR
Copy link

OGDR commented Oct 9, 2022

All right, so just try to build it and see (I think the error from before is because the modified version mentioned in the post is based on lineage os and it is different from aosp.

Aicp uses lineage base and tosses out what it doesnt use when it comes to its own base. Its in the default.config
It regenerated but the whent back way way back. Its gonna be a whole what the heck happened.
IMG_20221009_080226

@verNANDo57
Copy link
Author

verNANDo57 commented Oct 10, 2022

All right, so just try to build it and see (I think the error from before is because the modified version mentioned in the post is based on lineage os and it is different from aosp.

Aicp uses lineage base and tosses out what it doesnt use when it comes to its own base. Its in the default.config It regenerated but the whent back way way back. Its gonna be a whole what the heck happened. IMG_20221009_080226

Perhaps your computer is not powerful enough to perform this task. A lot depends not only on the memory size, but also on the PC configuration. Anyway, if it freezes, that doesn't mean that it won't unfreeze, you should just wait.

I faced the same problems when I had slow samsung laptop (RC530), it always froze on metalava. I always had to wait for about a hour or two. Just try doing what I did back then, if it doesn't help that means something is wrong with sources.

Good luck!

@OGDR
Copy link

OGDR commented Oct 10, 2022

All right, so just try to build it and see (I think the error from before is because the modified version mentioned in the post is based on lineage os and it is different from aosp.

Aicp uses lineage base and tosses out what it doesnt use when it comes to its own base. Its in the default.config It regenerated but the whent back way way back. Its gonna be a whole what the heck happened. IMG_20221009_080226

Perhaps your computer is not powerful enough to perform this task. A lot depends not only on the memory size, but also on the PC configuration. Anyway, if it freezes, that doesn't mean that it won't unfreeze, you should just wait.

I faced the same problems when I had slow samsung laptop (RC530), it always froze on metalava. I always had to wait for about a hour or two. Just try doing what I did back then, if it doesn't help that means something is wrong with sources.

Good luck!

Thanks

@OGDR
Copy link

OGDR commented Oct 10, 2022

All right, so just try to build it and see (I think the error from before is because the modified version mentioned in the post is based on lineage os and it is different from aosp.

Your configurtion worked. I finally got past the meta lava. Build is almost done.
IMG_20221010_053406

@kozlu14
Copy link

kozlu14 commented Oct 21, 2022

Hello I creatin lineageos 19.0 but ı 8gb ram wit build rom but lineage/out/soong/.bootstrap/bin/soong_build /mnt/ssd/lineage/out/soong/build.ninja ı can't pass, even it take my time, ı looked at what was said here, but you did not understand anything, can you help me please.

@KingProNoob2
Copy link

If you have 8gb of ram, i recommend at least a 24gb swapfile.

@KingProNoob2
Copy link

(you can Google how to add one)

@kozlu14
Copy link

kozlu14 commented Oct 21, 2022

How do i do it?

@KingProNoob2
Copy link

@kozlu14
Copy link

kozlu14 commented Oct 22, 2022

hello ı have 8gb ram and 27gb swap but not build android.

@kozlu14
Copy link

kozlu14 commented Oct 22, 2022

Uploading IMG_20221022_181001.jpg…

And eşit but close terminal

@kozlu14
Copy link

kozlu14 commented Oct 22, 2022

Uploading IMG_20221022_181001.jpg…

And eşit but close terminal

@kozlu14
Copy link

kozlu14 commented Oct 23, 2022

Hello how do create cmd.BuildTool

@OGDR
Copy link

OGDR commented Oct 26, 2022

Hello how do create cmd.BuildTool

Its already there you have to change the heap. Lineage is currently combing to files into one. I post later. What your gonna do is change the value on every of heap. Once you do this it will build.

@Niyush-04
Copy link

will this work for android 13?

@verNANDo57
Copy link
Author

will this work for android 13?

I don't think so, try searching guide for A13.

@PowerX-NOT
Copy link

will this work for android 13?

WELL my friend built los 20 with 8gb ram + 36gb zram (fedora)

@Niyush-04
Copy link

will this work for android 13?

I don't think so, try searching guide for A13.

Yupp these things are still working just have to increase Java max heap size limit by 1gb more.

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