Probably many guides are available on the Internet right now ! Motivation of writing the article is to share my experiences and some tips and tricks I have received from android development community.
I will be considering Linux build environment for the sake of this article. (as most of developers use local machine as well as servers which are Linux based.) Also you should be using a Linux based OS especially Debian based, if you are just starting as more support is available for it !
You can view requirements preferred by AOSP here
Establishing a Build Environment
Now most of ROM development takes place via cloud servers such as GCP (Google Cloud Platform), Azure cloud and other cloud providers, as compilation requires a lot of Disk space with processing power, but people who meet the requirements do compile on their local machine such as desktops and also laptops.
For a debian based environment such as Ubuntu( AOSP recommends Ubuntu LTS (14.04) and above ) the following are packages required =>
Use package manager
apt to install these packages. More or Less could be necessary depending on which ROM you are building and their implementation
sudo apt-get install \ adb autoconf automake axel bc bison build-essential ccache clang cmake curl \ expat flex g++ g++-multilib gawk gcc gcc-multilib git git-core git-lfs \ gnupg gperf htop imagemagick kmod lib32ncurses5-dev lib32readline-dev \ lib32z1-dev libc6-dev libcap-dev libexpat1-dev libgmp-dev liblz4-* liblz4-tool \ liblzma* libmpc-dev libmpfr-dev libncurses5-dev libsdl1.2-dev libssl-dev \ libtinfo5 libtool libwxgtk3.0-dev libxml-simple-perl libxml2 libxml2-utils \ lzip lzma* lzop maven ncftp ncurses-dev patch patchelf pkg-config pngcrush \ pngquant python python3 python-all-dev re2c rsync schedtool squashfs-tools subversion \ texinfo unzip w3m xsltproc zip zlib1g-dev zram-config
Also a simple automated script is available at android_build_env.sh by Akhil Narang.
For people who want to have a separate build environment can use Virtual Machines or Docker container.
Here is a Docker Environment Script ready to be used as a build host ; )
Installing Source Control Tools
We have already installed Git with all the dependencies.
mkdir ~/bin PATH=~/bin:$PATH curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo chmod a+x ~/bin/repo
git config --global user.name "Your Name" git config --global user.email "email@example.com"
Note: remember the email you use above will be used for git commits(if you do so), and will be available to anyone if you push to github.
Now that you have setup tools and dependencies needed, next step is getting the source code !
Next in Series : AOSP Rom Development - Syncing Sources