Build/Compile Android ROMs directly from Source! (Noob friendly guide)

Published by Shubham Mapari on

If you’re somewhat geeky you might get bored by using the same UI on your Android phone and might go Google some ROMs for your device, and guess what? There are no ROMs available! And you have no clue how to make one by yourself, so today I’m writing the tutorial on How To Build Android Custom ROMs from source! 

To build Android ROMs you need to be on a Linux machine, I personally use Ubuntu 17.10 but any other Linux distro should work well!

Step 1: Settin up environment. 

To get started you should have basic knowledge of Linux terminal.
Now install the following packages:

sudo apt-get install openjdk-8-jdk

 sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip

Step 2: Configure repo and git:

sudo -s

mkdir ~/bin


curl > ~/bin/repo

 chmod a+x ~/bin/repo

Step 3: Configure git with username & email:

git config –global “username”

git config –global “email”

Step 4: Download the source code of the ROM you want to build:

mkdir newrom

cd newrom

Just go to the manifest of the ROMs github and you’ll find the command to download source:
for e.g:

repo init -u git:// -b cm-14.1

 repo sync

These are commands to download LineageOS sources:
(sources are around 20GB+ so you’ll need good internet connection and patience)

Step 5: Getting kernel sources, device tree & vendor blobs:

just google for them and clone them in working folder 🙂

I’ll clone OnePlus2’s kernel sources for demo 

Clone/Download URL=
So, command to code will be:

git clone -b 5.1.1 kernel/oneplus/msm8994

-b = branch (you will see it on the git page)
branch is followed by directory ignore the first word after ‘/’ here it is android.
where you see an underscore replace it with slash.

cloning is same for the device tree & vendor blobs as-well.

Now to test if your ROM will compile or not, we use the following commands:

. build/


If you see your device listed there like mine will be ‘lineage_oneplus2-userdebug’ then go and enter the number corresponding your device and hit enter, If you can see details about your device then congrats you’re ready to build.

Now enter the build command (may differ with ROMs, refer your ROM’s GitHub)
For lineageOS it is:

brunch lineage_devicename-userdebug 

So for device OnePlus 2 it will be:

brunch lineage_oneplus2-userdebug 

Now the build process will start, this might take time depending upon your PC’s hardware. The ZIP file will be located in the OUT folder inside your working directory. 

Done, so this was a brief guide on how to build a ROM from source, if you have any questions or errors put ’em in comments below.

Categories: Tutorials

Shubham Mapari

A huge tech enthusiast and a passionate geek. Loves to play with Android. Astronomy is my first love then comes tech & programming!

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: