[Guide] How-To Compile Your Favorite Android ROMs


Hey fellow Droidsters,

In this post I will be teaching you how to set-up Ubuntu 14.10 and start building your favorite Android ROM yourself...

Please do note that this is not a guide to build your own custom ROM, rather it's a guide showing you how to compile your favorite ROM instead of waiting for Devs to do so.

I will be using various guides from XDA here. So nothing is from me, just what I found that worked for me. And the example ROM I will use is CM, since it's what most use.

So here we go...



Guide by sylentprofet on XDA

- First off Configuring Ubuntu :

Follow the directions step-by-step. All you have to do is copy and paste the code sections in order and you will be up and running in no time!

This guide applies to all variations of Ubuntu 14.10 Utopic Unicorn 64 bit. Do not use the 32 Bit version.

Also, PAY CLOSE ATTENTION when to use "sudo" and when to not. It can make things funky if you do something as root that you shouldn't.

Much thanks goes out to Google, ProTekk, Canonical, and everyone else that I read a random paragraph here and snippet there.

Ready to begin? Ok.

1) Unless it's a completely fresh Ubuntu installation, many of you may have the wrong version of Java installed. Let's fix that first.

The command below makes sure you're starting with a clean slate. Copy and paste it into a terminal (command prompt) window:
sudo apt-get purge openjdk-\* icedtea-\* icedtea6-\*

 If necessary, follow the on-screen instructions to remove any previous versions. Otherwise, move on to the next step.

It's time to install Java, one of the core pieces for compiling Android ROMs. Depending on which version of Android you are building, you will need the corresponding version of the Java Development Kit.

2) Install Open-JDK 7 for the necessary Java development tools.
sudo apt-get update && sudo apt-get install openjdk-7-jdk

Follow the on-screen instructions.

3) Let's make sure the correct version of Java is activated. Run the terminal command:
java -version

 You should see something like OpenJDK 1.7

5) Back to a fresh terminal prompt. Install the main build tools with this command:
sudo apt-get install git gnupg ccache lzop flex bison gperf build-essential zip curl zlib1g-dev zlib1g-dev:i386 libc6-dev lib32bz2-1.0 lib32ncurses5-dev x11proto-core-dev libx11-dev:i386 libreadline6-dev:i386 lib32z1-dev libgl1-mesa-glx:i386 libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown libxml2-utils xsltproc libreadline6-dev lib32readline-gplv2-dev libncurses5-dev bzip2 libbz2-dev libbz2-1.0 libghc-bzlib-dev lib32bz2-dev squashfs-tools pngcrush schedtool dpkg-dev

6) When those are done installing, run the next line in your terminal window:
sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so

That's it on the package side of things. You guessed it, time for more Terminal. This really is the easiest way, I promise.

 7) A program called "repo" lets you communicate with git servers and download all that precious source code. The next command will install it:
mkdir ~/bin && curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo && chmod a+x ~/bin/repo

8) Use your favorite text editor to open ~/.bashrc - I like nano:
 sudo nano ~/.bashrc

9) At the very bottom (use the Page Down key) paste this code to a new (empty) line:
 export PATH=~/bin:$PATH

10) Save it. In nano that would be Ctrl-O and then Enter. Then Ctrl-X to exit back to a prompt. Restart bash:
 source ~/.bashrc


- Now on to Compiling CM12 :

Run the following commands in terminal and you should be on your way to compiling your first ever CM12 ROM for your device...

Note : Before we start, make sure you got the device tree for your device, I recommend you ask around see what it is and what the git url is etc...

1) First run this command to create the work Directory :
$ mkdir -p ~/CM

 2) Now navigate to created directory via this command :
$ cd ~/CM

3)  Time to configure your username and email :
git config --global user.name "your username"
git config --global user.email your email

4) On to initialize the CM Repo : (Replace with your ROM git)
$ repo init -u https://github.com/CyanogenMod/android.git -b cm-12.0

5) Ok, this will take some time, depending on your connection, syncing the CM repo :
$ repo sync

6) Once that's done, it's time to clone the Vendor folder : (Replace with your ROM/Device Vendor)
$ cd Vendor
$ git clone https://github.com/TheMuppets/proprietary_vendor_lge.git

7) Rename folder in vendor from android_vendor_lge to lge

8) Before we begin the compilation go back to root CM directory and initialize via them 2 commands
$ cd ~/CM
$ source build/envsetup.sh

9) Finally time to compile... This will hammer your CPU and take anywhere from 5 to 12 hours depending on your machine specs. The higher end CPU the faster you will build. That's why I do not recommend VMs coz this will triple the time this will take.
$ brunch your device name

P.S :  I recommend you always make clean. Removes any issues. You do that by running the following command after syncing the repo and before envsetup.. then run compile command.
$ make clean


--------------------------


I really hope that this helps you get to know how to compile your Favorite ROM. Maybe soon you will also be able to actually build your own custom ROM... ;) 

0 comments:

Post a Comment