[Galaxy S II Android Development] Vivek_Neel:
****NOOB GUIDE ON HOW TO BUILD CM OR CM BASED ROM FROM SOURCE FOR S2****

****FULL SUPPORT ****​

So guys from the concept of sharing and caring ..am going to share the way through which i have succeeded to compile my first rom based on omni source.

I will try to make this guide as much as easy ..so dont worry..and feel free to ask any doubt if u have..

Note: Most of the instructions are fit for Ubuntu running normally on any PC and not specific to Virtual Box

Things Required:

**Computer/Laptop with decent amount of ram (min 6gb)and also decent storage

**Internet connection(now thats obvious)

**Some knowledge about linux commands..like basic command such as cd for “change directory”,(anyways even if u dont know just copy and paste the codes given in the thread

**Last but not least "U must have android mobie" not an iphone (kidding)

This Guide will cover below things:

** How to install Ubuntu on virtual box

**How to set up Build environment

**How to build and compile rom

**transfer the zip from ubuntu to your phone

So lets begin

How to install ubuntu on Virtual box:

1. Download ubuntu from HERE(download ubuntu 12.04 LTS 64 bit)if u are having system with 2gb then pls dont try to compile

2. Download virtual box from HERE(download the latestwindows version x86/amd64)

3. After downloading vm click on it and select "NEXT"

4.Choose not to install USB support, networking, or Python support. Do this by clicking the grey icon near each option and selecting the red X or “Entire feature will be unavailable”. Then click “Next” to continue.

5.Uncheck the Quick Launch Bar checkbox and click “Next” to continue

6.Click install and finish.

7.Now click the new button at the top to create a new virtual machine.

8.Give your virtual machine a name and select the operating system you’ll be running(for e,g select version as ubuntu 64 if u are on 64bit os). Click “Next”.then slect create virtual hard drive now

9.now type the amount of memory ..(4gb is absolute minimum)

10.Click “Next” to create a new virtual hard disk, then click “Next” again

11.Select dyanmically allocated storage

12.now type the amount of storage(200 gb is minimum) and click create .

13.Select your new virtual machine. Once you've done this, click the “Settings” button.

14.Click “Storage” tab and Click the “CD/DVD icon" having "+" on it and select ISO to mount.

15.Click system on the left and Choose boot order and keep CD/DVD on the top as first priority.

16.Now close the settings window and Select your virtual machine. Then click the “Start” button

15.Now ubuntu will start and select the language

16.select install ubuntu

17.click continue and select the first radio button ..then hit continue again and install now(wait for some time)

18.Go through all the steps and finally u should have the below screen.(if u have got that screen then u are ok to proceed ahead )

16.So i assume you have got the ubuntu desktop .

17.click on ubuntu software centre avaliable on the left side and select edit/software sources

18.click on update tab and follow the screenshot below

19.After couple of min u should see update box is dancing:D on the left side , click that and install all the update packages

How to set up build environment:

1. Go to THIS awesome thread , I Bet u would not have any problem in setting up build environment if u had followed it correctly..

2.If u have any troubles in setting up build env then u are free to ask/post in this thread.

3.You can also set up adb and fast boot very easily instead of sdk tools (but remember it does not mean u can skip downloading sdk tools, you have to download all the packages .

Set up adb and fastboot with ease

4.you only need to download the below packages

JDK 6

Python

Git 1.7

Android SDK

ia32libs

So i assume you have set up your build environment successfully ..

How to build and compile :

1.We will install build packages needed to compile the rom.

2.Open your ubuntu terminal by pressing ctrl+alt+t

3.As of now u cannot copy/paste text between ubuntu and your windows ..so we will be installing guest addition cd image which u can install by clicking on Devices/install guest addition cd image .

4.it will install now , after that select Devices/share clipboard/bidirectional ..now reboot your ubuntu by typing the below code in terminal

sudo reboot

5.Now copy paste the below code in terminal to install build packages

sudo add-apt-repository ppa:ubuntu-toolchain-r/test

sudo apt-get update

apt-get install g++-4.7 gcc-4.7

For 32-bit & 64-bit systems

git-core gnupg flex bison gperf libsdl1.2-dev libesd0-dev libwxgtk2.8-dev squashfs-tools build-essential zip curl
libncurses5-dev zlib1g-dev openjdk-6-jre openjdk-6-jdk pngcrush schedtool

For 64-bit only systems

g++-multilib lib32z1-dev lib32ncurses5-dev lib32readline-gplv2-dev gcc-4.7-multilib g++-4.5-multilib

6.You should not have any problem in installing the above packages if u had followed it correctly.

7.Now Create the directories

mkdir -p ~/bin

8.Install the repo command

:

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

9.Important thing now is u have to put the bin directory in your path of execution..to do so ..copy and paste the below code

export PATH=${PATH}:~/bin

10. type

gedit ~/.bashrc

and now paste

export PATH=${PATH}:~/bin

11.save it by pressing ctrl+x

12. now we have to create a directory in which our source will get downloaded

mkdir -p dirname

(type the directory name )

cd dirname

13.Now its time for us to initialize the repository

Syntax :

repo init -u url -b branch

for e.g am going to fetch omni source..so i wil type as

repo init -u https://github.com/omnirom/android.git -b android-4.4

for pacman

repo init -u git://github.com/PAC-man/pacman.git -b pac-4.4

for slimbean( google, exynos and non qcom devices)

repo init -u git://github.com/SlimRoms/platform_manifest.git -b kk4.4

slimbean(for qcom devices which are using CodeAuroraForum trees)

repo init -u git://github.com/SlimRoms/platform_manifest.git -b kk4.4-caf

for cm

repo init -u git://github.com/CyanogenMod/android.git -b cm-11.0

14.then go to THISanother awesome thread to understand about the local manifest ,manifest and many more..(this thread is highly recommended to those who have poor internet connection)

15.IF u are lazy and dont want to go throu the above thread then u can skip and follow the below steps.

16.type

repo sync -c -j4

Note: if u have low bandwidth the use -j2 instead of -j4 and if u have good internet connection use -j16 instead of -j4

repo sycn -c will download only the current version so it saves time for u

17.repo sync will take more time..(for me it took 3 days to complete because my internet speed was 50kb/sec

18.After repo sync is done u have to fetch some additional repoistory using local_manifest.xml

<remote fetch="https://github.com/DonkeyCoyote" name="donkey" />
<project name="DonkeyCoyote/proprietary_vendor_samsung" path="vendor/samsung" remote="github" revision="android-4.4" />
<project name="android_device_samsung_i9100" path="device/samsung/i9100" remote="omnirom" revision="android-4.4" />
<project name="android_device_samsung_galaxys2-common" path="device/samsung/galaxys2-common" remote="omnirom" revision="android-4.4" />

thanks to chasmodo

note: above is an example for omni rom...if u are fetching aokp,pac etc then u have to change the path , remote , revision accordingly

19.Let's configure ccache too. It will reduce the build time to 40% after first build

echo "export USE_CCACHE=1" >> ~/.bashrc

directoryname/prebuilts/misc/linux-x86/ccache/ccache -M 25G

25G means it will use upto 25 gb of disk space for ccaching. Atleast 10 gb is recommended.

20.Now its time for compiling .simply type

. build/envsetup.sh

brunch i9100

21.it may take some time depending upon your pc/laptop configuration

22.u should get package complete at the end..(unfortunately i could not save screenshot of that..but soon s.s will be posted when i repo sync again)

23.If yes then u have successfully built your rom ..congrats:good:

24.now how to transfer that zip to the phone for flashing?..follow the below steps

how to transfer files from ubuntu to your phone:

1: Download and install the AirDroid app to your Android device.

2: Launch the app and read the starter guide. As soon as you’re done, click “Start”.

3: Take note of the web address that is being shown on the app. You’ll need that web address to access your smartphone through your computer’s web browser.

4.now type the code in ubuntu browser and there u go ...u have connected your phone to ubuntu.

5.transfer the file by selection files/sdcard/upload

6.Done

Hope this guide helps u the most.

IF U HAVE ANY QUESTION FEEL FREE TO POST ..cheers.

GOOD LUCK:good:

Credits:

[MENTION=3816568]Myself5[/MENTION] (this guy really deserves it)

[MENTION=4406720]chasmodo[/MENTION] [MENTION=3973489]engloa[/MENTION]

google

Hit the thanks button if u think it deserves to have..:highfive: