Building Android from its source code is not for everyone. Why? Because it requires tons of patience and ungodly amounts of memory and processing power. Are you aware that the AOSP repository is, as of winter 2017, at least 31 GB, even if you run the
repo init command with the
--depth option set to 1? And did you know that the output of the build process is almost 8-9 GB? Well, now you do. So, do you think a run-of-the-mill laptop will be able to handle that kind of load? Let’s answer that question a little while later.
For now, let’s see what the recommended hardware configuration is for custom Android ROM development. To start, you’re going to need around 9-12 GB of RAM. AOSP uses the Jack toolchain for builds, which is a huge memory hog. Additionally it uses
javadoc extensively, which seems to sometimes consume 10-12 GB of memory all by itself.
Now, the problem is that Jack runs as a server, and once it consumes some memory, it doesn’t release it soon enough. That means, Jack and
javadoc can potentially run in parallel sometimes. When that happens, you will encounter memory allocation errors even with 10+ GB of RAM. You could add more RAM, but, in my opinion, that’s not always necessary. You have the option of using swap files. I recommend having anywhere from 6-8 GB of swap space available during builds.
Using an ordinary hard disk for swap space is okay, but using an SSD is way better because its latency would be much lesser. In fact, the SSD doesn’t have to just serve as swap space. It can double as the storage location for the compiler cache, dramatically improving build times. How big can the compiler cache be? I have seen it grow to about 20 GB. If I am building the ROM for multiple devices, it can easily reach 50 GB too.
Lastly, you’ll need a good processor. Fortunately, good processors are not that rare. Most laptops have a quad core processor, and that’s good enough.
So, to sum it all up, for a smooth, quick, and error-free build, the system requirements are:
Are there any laptops that meet those requirements. Of course! Here are just a few you can find on Amazon:
Most of them are quite pricey. Yes, apparently $500 or more is what you need if you want to become a full time custom ROM developer. Anything less, and you’ll likely end up spending your days waiting for builds to complete, encountering weird errors–such as “Jack server connection timed out”, “communication error with Jack server” and “native memory allocation failed to allocate (X) bytes”– and sometimes running
make clobber to clean stuff up and restart the build from scratch.
Don’t get disheartened though if you don’t have such a laptop. If you really do have the patience, and I mean being ready for 20+ hour build times, let me assure you that you can build AOSP with even just 4 GB of RAM, an ordinary hard disk, and an Intel i3 processor. I used to do it until recently. Yes, all you need to do is allocate about 15 GB of hard disk space for swap and about 40 GB of hard disk space for
ccache. Once you do that, and you start the build, you might still encounter one or two hiccups in the form of “communication errors with Jack server”. When you do, you can simply kill the Jack server and restart the build from where it stopped. During the build, you might see that your CPU usage is less than 1-2% and your memory usage is 99.5%, essentially making your laptop unusuable. But let it go on. At the end of 20 or so hours, you will have successfully built your ROM. But, obviously, you can’t do any meaningful development with that kind of build times. I mean, imagine making a small change in the code and waiting for 6-10 hours to test it. Oh, yes, if you didn’t already know, after a full build, subsequent builds will be much faster.