How to Compile Your Own Android Nightlies (and Learn Something in the Process)

Hi everyone! Have you ever wanted to compile your own nightlies, but are too intimidated or “not a dev”?

I’ve decided to write a guide about how you too can enter the wonderful world of development.

Before we begin, I’m going to say one thing. PLEASE GOOGLE YOUR QUESTION FOR AT LEAST 5 MINUTES BEFORE ASKING IT HERE. Developing isn’t an easy thing. You should maybe know a little bit of Linux going into this. If not, prepare yourself for some reading. This isn’t the place to ask how to install Ubuntu or why you need 64 bit. Just have a little faith and trust me.

For all intents and purposes, this guide will show you how to set up your system and compile ROMs based on AOKP for the Nexus 4 (mako). I’ll let you know what parts to change that apply to your specific device. I suppose I should thank Google, Cyanogenmod, Team AOKP, a few others. You know who you are.

On with the show.

Here’s a list of things you will need:

1) A decent computer (at least dual core, 2+ gig of RAM, 50 gig free HD space) capable of running 64 Bit Linux (32 bit PCs will not work!)
2) A fresh install of BuilduntuVM
3) Spare time and the desire to learn.

You need to make a decision at this point. What flavor of Android do you want to build? In other words, AOKP, Cyanogenmod, AOSP, etc etc etc.

I’m going to base this guide on AOKP Kitkat because I know it works.

First create a folder to initialize the repo for sourcecode.

mkdir ~/android
cd ~/android

The following command will do the actual initialization:

repo init -u https://github.com/AOKP/platform_manifest.git -b kitkat -g all,-notdefault,mako,lge

The above code is what you would change if you would want to build Cyanogenmod or other kangs. Do some googling and you will find the appropriate command you need. Include the keywords “git” and “repo” in your search, and read!!

Devices are given a “development codename”. In the case of this guide, we are working on the LG/Google Nexus 4, which is known as the “mako”. Do some research on your specific device, I recommend XDA Developer Forums. You’ll figure it out quickly.

After this next part you’re going to want to take a break. It’s time to actually download to your computer (sync) the source code. As of writing this guide, that’s over 10 gigabytes of information, depending on the “flavor” of Android. In the terminal:

repo sync

Don’t worry, you can just set it and walk away. Depending on the speed of your connection, this could take a long time. Anywhere from one hour to “maybe-you-should-do-this-before-you-go-to-sleep”.

When that finishes downloading, it’s time to start the actual compiling.

This next bit will probably take a while also, but again, it’s a set-it-and-forget-it situation.

Start with a fresh terminal:

cd ~/android
source build/envsetup.sh
lunch

(select your device using the number in the list)
make otapackage

 

That will do it! Watch for errors, but everything should work at this point. Again, how long this takes is completely dependent on the power of your computer. If it completes without a hitch, you’ll have a flashable zip file located in ~/android/out/target/product/deviceName/

Congrats, you just compiled from source! Now, if you really want to get adventurous, you can start delving into the code itself and make some changes. But this post isn’t the place to get into all that. Good luck, and please say thanks if this guide was helpful!

If you appreciate my hard work, feel free to buy me a coconut water (donate). It would be greatly appreciated!

3 comments

  1. Great tutorial. Arn,t there hybrid builds now. For example cm 10.1 nightly, linaro tool chain build with cherry-picks. AOKP

    how would one go about buildind one of those ROMs? The tutorials are scattered and obscure at best on the xda forums.

    Thanks

Leave a comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.