[Android] Anik_khan:
Hi All,

I and [MENTION=5854483]akhilnarang[/MENTION] decided to post this guide to help anyone wanting to learn building of Roms and kernels. We will be using Ubuntu 14.04 Trusty Tahr here.

You can find instructions to install it elsewhere, just remember rom building needs 64bit OS, minimum 4GB RAM, and 100GB space on HDD. Kernel can be built on less hardware, but will take long

Make sure you have fast net, as you have to download at least 16GB of ROM sources, or more kernel, only 1GB of sources max.

Be prepared to spend a lot of time downloading, learning, and fixing bugs :D

More RAM, or faster CPU, or SSD will speed up the process.

From our personal experiences we have found that this is the best, stable, up-to-date version of Ubuntu yet. This has come from my trial and errors, searching all over the web, and bits I picked up from here and there.

We will move Rom building part when we completed this step properly. Step by step we will learn compiling kernel, using Github, Gerrit, Cherry-picking.

At the end of the post I have linked a script by [MENTION=5854483]akhilnarang[/MENTION] which if run will automatically install all these programs for lazy people like us haha [emoji14]

If you not interested to do all procedure from below just use the script. Simply it will automatically configure the build environment.

NOTE-------- some of these packages may already be on your machine. Obviously, if you complete a step and you have one of these installed, the machine simply will not do anything. So...it will not hurt anything. Some of the packages are different from Ubuntu 12.04 and 13.04 (use these packages for Ubuntu 14.04 as many of the old ones have obsoleted - these are new replacements).

So if you set up your pc with Ubuntu we are good to go.

All code will be in code boxes like this:

$

means you have to run that command in the terminal (don't type the $).

All commands with sudo, gksudo, or gksu means it requires root permission.

It will ask for password.

Once you type, then in that terminal session it will not ask you for a few minutes again.

Any time you make changes to .bashrc or .profile file, make sure to run

$ source ~/.bashrc
$ source ~/.profile

Or exit and open new terminal else the changes will not take place

Setting up build environment:

Installing Java JDK

Note: You need JDK 7 when you willing to compile Lollipop. If you wanna compile KitKat or lower you need JDK 6.

Open terminal (CTRL + ALT + T)

Then execute the following commands in terminal one by one:

Download & install java

$ sudo apt-get update && sudo apt-get install openjdk-7-jdk openjdk-7-jre

CHECK if java properly installed or not

$ java -version

If you get output like

java version "1.7.0_79"

on the first line then all is good :D

Now JDK is configured!

Note: Only for Ubuntu 14.04 or higher

Installing Required Packages

Open Terminal

Now execute this command:

Note: This will take some time, has to download about 500MB or so of packages

$ sudo apt-get update && sudo apt-get install git-core python gnupg flex bison gperf libsdl1.2-dev libesd0-dev libwxgtk2.8-dev squashfs-tools build-essential zip curl libncurses5-dev zlib1g-dev openjdk-7-jdk pngcrush schedtool \
libxml2 libxml2-utils xsltproc lzop libc6-dev schedtool g++-multilib lib32z1-dev lib32ncurses5-dev lib32readline-gplv2-dev gcc-multilib liblz4-* android-tools-adb android-tools-fastboot ccache

Configuring USB Access

Now we need to set permissions so that our USB ports can detect our android devices [emoji14]

Type in the following commands, it will download a file with the permissions, give it permission to execute, and restart the service.

$ sudo curl --create-dirs -L -o /etc/udev/rules.d/51-android.rules -O -L https://raw.githubusercontent.com/snowdream/51-android/master/51-android.rules
$ sudo chmod 644 /etc/udev/rules.d/51-android.rules
$ sudo chown root. /etc/udev/rules.d/51-android.rules
$ sudo service udev restart
$ sudo killall adb

ADB & Fastboot are configured

Installing Repo Package

Open terminal and type:

$ mkdir ~/bin
$ PATH=~/bin:$PATH
$ curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo

Configure Git

Open terminal and type:

$ git config --global user.email ""
$ git config --global user.name ""

Git is configured.

Configure ccache

Open terminal and type:

$ gksu gedit ~/.bashrc

Enter these lines

export USE_CCACHE=1
export CCACHE_DIR=~/.ccache

Save & close

Open terminal & execute:

$ source .bashrc
$ ccache -M 50G

I usually use 50 gigs. You can use more if you have more space, or build for many devices

Make a GitHub account using the same email address you used for configuring git

Then follow these

So if you not interested in doing above all steps then simply use this script by my friend [MENTION=5854483]akhilnarang[/MENTION]

Open terminal and type:

$ sudo apt-get install git-core

then do

$ git clone https://github.com/akhilnarang/scripts.git
$ cd scripts
$ . build-environment-setup.sh

This script will install all required packages :D

Congrats :D

YOUR BUILD ENVIROMENT IS NOW SETUP :D

Now move onto #2nd post for Git and repo tutorial

To be continued :)