[ DIY ] How To Compile Your Own Nightlies (and Learn Something in the Process)

sylentprofet

Senior Member
Jun 10, 2010
283
1,857
0
Sacramento
--- copied with permission from nathanpfry.com ---​

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

For various reasons, 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. I'll probably repeat it a bunch of times too, to be sure everyone reads it at least once while skimming through this. PLEASE GOOGLE YOUR QUESTION FOR AT LEAST 5 MINUTES BEFORE ASKING IT HERE. The main reason I wrote this guide is to try to refocus the point of the "Development" forums on XDA. There are many users out there that seem to think this is a place to make demands for answers without trying to contribute or learn anything themselves. Developing isn't an easy thing. You should know a little bit of Linux going into this, if not, prepare yourself for some reading. This isn't the place for you to ask how to install Ubuntu, or why you need 64 bit. Just have a little faith and trust me.

Major thanks goes out to Hashcode.. Seriously, you have no idea what an inspiration he's been. For all intents and purposes, this guide will show you how to set up your system and compile ROMs based on his work, perhaps even help work on fixes. I suppose I should thank google, cyanogenmod, team aokp, thingonaspring (minimoto rocks!) 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 Linux
2) A copy of Builduntu
3) Spare time and the desire to learn.

Double check that your main system is 64 bit. 32 bit OS will not work!

Once you get Builduntu up and running (there are instructions @ the above link), read on.

You need to make a decision. What flavor of Android do you want to compile? In other words, AOKP, Cyanogenmod, AOSP, LiquidSmooth, SimpleAOSP etc etc etc.

For the purposes of teaching everyone, I'm going to base this guide on AOKP.

You've made it this far, you're basically almost there. *cue motivational montage music*

When Builduntu says, "initialize the build repo", that means to sync your source code with a git repository. Run these commands in a terminal:

Code:
mkdir ~/android
Code:
cd ~/android
The following command will do the actual initialization:

Code:
repo init -u https://github.com/AOKP/platform_manifest.git -b jb-mr1
Ok, 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, it is over 10 gigabytes of information, depending on which "flavor" of Android. In the terminal:

Code:
repo sync
Don't worry, just execute and walk away. Depending on the speed of your internet connection, this could take a long time. Anywhere from one hour to "maybe-you-should-do-this-before-you-go-to-sleep". Up next is actually doing the compiling.

When that finishes, you have the source code. Let's get to business. This next bit will probably take a while also, but again, it's a set-it-and-forget-it situation.

Code:
cd ~/android
source build/envsetup.sh
lunch yourdevicenamehere
make otapackage
That should do it! Watch for errors, but everything should work at this point. Again, how long this takes is completely dependent on how fast your computer is. If it completes without a hitch, you'll have a flashable zip file located in ~/android/out/target/product/yourdevicename/

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!

PLEASE PLEASE PLEASE If you happen to find an error in my guide (not just a question about it!) PLEASE PM ME. I will give you credit in the post. A potentially useful fix could be buried pages deep in the thread and unfortunately get lost if it's only a reply. Thanks!
 
Last edited:

docardoso

Member
Jan 8, 2013
14
6
0
Many thanks!

Although I didn't tried this howto yet, I feel obligated to thank you for this. In the past I though about trying to do something directly tweaking the code and, who knows, contribute with something nice to our "D3 society". But could never figure how to start it. I will spend some time trying to make it work using this "manual" and give some feedback about it.

Again, thanks. :)
 
Last edited:

Hashcode

Senior Recognized Developer
Sep 3, 2011
3,426
23,729
0
Re: [DIY] How To Compile Your Own Nightlies (and Learn Something in the Process)

Great post.

Sent from my XT926 using Tapatalk 2
 

Caldair

Senior Member
Dec 28, 2008
616
673
123
Thanks for this awesome guide! I followed your directions and did produce a zip that I can flash with safestrap. Unfortunately it will not boot though:crying: Is there anything else to do with the kexec zip to make it safestrap compatible? Or did I just screw something up:confused:

Either way I am glad I did this and without your 2 great guides I never would have. So thank you again sylentprofet! :highfive:
 

sylentprofet

Senior Member
Jun 10, 2010
283
1,857
0
Sacramento
Thanks for this awesome guide! I followed your directions and did produce a zip that I can flash with safestrap. Unfortunately it will not boot though:crying: Is there anything else to do with the kexec zip to make it safestrap compatible? Or did I just screw something up:confused:

Either way I am glad I did this and without your 2 great guides I never would have. So thank you again sylentprofet! :highfive:
Hmmmmmm. That is a frustrating problem. I've had it happen before..

Just tried a compile myself, and CM10 doesn't work. Silly me for thinking that everything would go smoothly. It could be some changes reflected recently on CM's end. The joys of development!

However, I just tried an AOKP 4.2 build, and it does boot. So I'm going to make some quick changes to the guide to reflect building for AOKP while I examine the code and see what's up.

There's nothing more frustrating when a build completes successfully and then won't flash. I'll keep everyone posted.
 
Last edited:

stretchnz

Senior Member
Apr 14, 2012
90
30
0
this looks amazing
thank you for spending the time to write this up!

May be up for a reinstallation of my Ubuntu (currently 12.04 x86 :/).
 
Our Apps
Get our official app!
The best way to access XDA on your phone
Nav Gestures
Add swipe gestures to any Android
One Handed Mode
Eases uses one hand with your phone