Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,738,692 Members 40,142 Now Online
XDA Developers Android and Mobile Development Forum

[TUTORIAL] Setting up and Compiling JB and ICS from AOSP

Tip us?
 
shenye
Old
(Last edited by shenye; 31st October 2012 at 11:53 PM.) Reason: updated to 4.1.2
#1  
shenye's Avatar
Retired Forum Moderator / Recognized Developer - OP
Thanks Meter 1303
Posts: 488
Join Date: Oct 2009
Location: London

 
DONATE TO ME
Default [TUTORIAL] Setting up and Compiling JB and ICS from AOSP

Quite a few people have asked about compiling ROMs from source, so here's a guide.

This guide is directed mainly at compiling JB or ICS for the GSM Galaxy Nexus.

It will show you how to set up the building environment really quickly with a few simple commands in the Terminal, then show you how to sync up with the repository and compile a ROM.

http://www.freeyourandroid.com/guide/compile-ics

It can also be done in a Virtual Machine.

Thanks Nathan (nprussell) for the write up!



My XDA TV Video Guide:

http://www.youtube.com/watch?v=H_ReU...14FUAAAAAAAZAA


---




Here are the steps:
(There are additional things you can do via the link above).




======================




IMPORTANT NOTES:

- For the purposes of this guide, you MUST be running 64-bit Ubuntu. This can be set up on a VM (it will compile if set correctly).
- If using a VM, ensure you give it at LEAST 2gb RAM and 2xCores (it'll take 3-4 hours at best)
- The source download is approximately 6gb.. you're going to need 25gb HD space for a single build.

To learn how to setup a Ubuntu 64bit VM on your Windows PC, use THIS GUIDE. I recommend using 10.04.

So... let's assume you're running Ubuntu 64 bit for the first time, and start right from the beginning.

NOTE : You're probably better of copying and pasting these commands, as some are quite long! All commands are in RED!


======================


1. Preparing your development environment

The very first thing you're going to need to do, is ensure you're working in a root terminal. Much like when using your Android phone, you'll want the # and not the $. In order to do this, open TERMINAL, and type:

sudo -i

Then type in your password. From this point forward, all of the commands in this guide assume you have root priviliges (saves typing sudo *superuser do* before everything!)

Next, we need to add a repository so that apt-get knows where to look for Java JDK:

add-apt-repository "deb http://archive.canonical.com/ lucid partner"

After that, you'll need to update the repository with the following command:

apt-get update

Now that your repository has been updated, you can proceed with installing the required packages to make building Android from source possible. The first thing you're going to need is the Java Development Kit 6:

apt-get install sun-java6-jdk

Followed by (and this may already be installed depending on which version of Ubuntu you went for):

apt-get install python

Now you're going to need Git. Git is the revision control system.

apt-get install git-core

Now, you're going to pull in all the required packages needed for the build process. As I have stated already, this guide is for 64 bit ONLY. Some of these will not work on 32-bit, so if you're using 32 bit, you're reading the wrong guide (sorry)!

apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev libc6-dev lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown libxml2-utils

IF YOU'RE USING UBUNTU 11.10, TYPE THIS COMMAND (if not, ignore this next one)

ln -s /usr/lib/i386-linux-gnu/libX11.so.6 /usr/lib/i386-linux-gnu/libX11.so

Congratulations; you now have all the required packages to proceed with the next step!


======================


2. Installing and initialising the repo

Now we need to download repo, add it to our path and set the permissions . Please note that if you close terminal, you'll have to do this again. Type each command on a new line, pressing enter after each:

mkdir ~/bin
PATH=~/bin:$PATH
curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
chmod a+x ~/bin/repo


Now we need to create a directory for where our source is going to be pulled to, and change directory to it:

mkdir ICS_SOURCE
cd ICS_SOURCE


Next, you'll need to initialize the repo. There are two commands below; the top one initializes the specific branch, and the bottom is the master.

ONLY USE ONE OF THE FOLLOWING COMMANDS (recommended - TOP)

ICS: repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.4_r1
Jellybean: repo init -u https://android.googlesource.com/platform/manifest -b android-4.1.2_r1

OR:

repo init -u https://android.googlesource.com/platform/manifest

You will now be prompted to provide your name and email address. Please give it real details; that way you can use the gerrit code review tool if your email is connected with a Google account.


======================


3. Downloading the source (sync)

This is probably the most simple part, but depending on your connection speed, it could take a while. I am on 40mb download/10mb up, and it took about 25 mins. If you're on a typical DSL connection, expect to be waiting 60-120 minutes.

repo sync


======================


4. Obtaining proprietary binaries

New for ICS, Android cannot just be compiled from source code only. It requires additional hardware-related proprietary libraries to run, specifically for graphics acceleration (and GSM/LTE).

The binaries must first be downloaded from here

Each set of binaries comes as a self-extracting script in a compressed archive. After uncompressing each archive, run the included self-extracting script from the root of the source tree, confirm that you agree to the terms of the enclosed license agreement, and the binaries and their matching makefiles will get installed in the vendor/ hierarchy of the source tree. For example... after extracting one of the files, you will have 'extract-imgtech-maguro.sh'. Simply run:

sh extract-imgtech-maguro.sh

From your ICS_Source directory.

IMPORTANT NOTE : If you are building for the Nexus S, you will need the Nexus S binaries.


======================


5. It's build time!

If you're a JAVA developer, feel free to have a play with the source and make any changes you want to make at this stage. Be careful though, adding rubbish/old syntax code to the source (formatting is slightly different to gingerbread) will cause the build to fail.

Assuming that you just want to get on with building ICS, set the build environment up with:

source build/envsetup.sh

Next, you'll need to lunch. I don't mean go and have a sandwich, I mean... select which device you're building for.

NOTE - you can add other devices to this list PRIOR to proceeding with this step. If you're NOT building for the GNexus, go to the bottom of this guide and look at how to add devices to the list.

As previously stated, we're going to assume you're building for the Galaxy nexus, so type:

lunch

You'll be presented with a number of options (full-eng, etc).


If you're building for the Galaxy Nexus (codename: Maguro), type:

8

(7 for Nexus S and 6 for Nexus S 4G)


and hit enter. Now, we're ready to set the compile in motion, ladies and gentlemen. There's a lot of debate over the next bit. the -j part of the below command is technically not needed, but I have had MUCH more success compiling on a virtual machine with the -j1 added. Could be random... who knows...

Anyway, to set your build in motion, you now have TWO options. The first option will output the build as img files. The second option will output a flashable .zip file. I recommend the latter if you intent to use CWM over fastboot.

make -j1

or

make -j1 otapackage

Congratulations - in a few hours, you should have a working AOSP build for the Galaxy Nexus!

Follow me on Twitter: @shen_ye
Circle me on Google+: google.com/+ShenYe
The Following 119 Users Say Thank You to shenye For This Useful Post: [ Click to Expand ]
 
sbice
Old
#2  
Junior Member
Thanks Meter 2
Posts: 1
Join Date: Feb 2010
thank you
i tried it ,and works fine

is there any easier way to debug ?
like using eclipse

i imported the source eclipse but no idea what the next steps are
The Following 2 Users Say Thank You to sbice For This Useful Post: [ Click to Expand ]
 
EddyOS
Old
#3  
EddyOS's Avatar
Recognized Contributor
Thanks Meter 2937
Posts: 13,150
Join Date: Jan 2010
Location: Liverpool, Merseyside
Thanks for this, will study properly when I get a chance

Sent from my Galaxy Nexus using xda premium
HTC One M8 (Gunmetal Grey) 16GB
ROM: 2.22.401.4 (KTU84L) | HBOOT: 3.18.0.0000 S-OFF | Recovery: Stock | Baseband: 1.19.2133147.09G_20.57.4196.01L_F | Kernel: Stock | CID: HTC__001

OnePlus One (Sandstone Black) 64GB
ROM: CyanogenMod 11S (XNPH25R)

If you have a question, great - but DO NOT PM ME WITH IT!!! | [GUIDE] Return your EU M8 to 100% Stock (S-OFF Required) | [GUIDE] Return your OPO to 100% Stock
 
shenye
Old
#4  
shenye's Avatar
Retired Forum Moderator / Recognized Developer - OP
Thanks Meter 1303
Posts: 488
Join Date: Oct 2009
Location: London

 
DONATE TO ME
@sbice try this http://www.javahotchocolate.com/tuto...se.html#64-bit

Follow me on Twitter: @shen_ye
Circle me on Google+: google.com/+ShenYe
The Following 5 Users Say Thank You to shenye For This Useful Post: [ Click to Expand ]
 
beekay201
Old
#5  
beekay201's Avatar
Senior Member
Thanks Meter 1119
Posts: 4,618
Join Date: Nov 2010
@op, Thanks, but at least, check the howtos you link to, there's missing steps there.
I dont agree these kind of threads should be in dev section.
hammerhead/omni-KTU84M/stock#3.4.0/M8974A-2.0.50.1.13
maguro/aosp-KRT16O/custom#3.0.101/XXLJ1
manta/stock-KRT16S/custom#3.4.39
tf201/cm10-NIGHTLY#20120820/stock#2.6.39.4
XDA forum rules here
bug report? logcat and /proc/kmsg, or it "never happened".
How TO Ask questions on the Internet
aosp-maguro READFIRST here (credit: efrant)
aosp-gnex READSECOND here (credit: efrant)
 
ljwnow
Old
#6  
Senior Member
Thanks Meter 138
Posts: 733
Join Date: Jul 2007
Quote:
Originally Posted by bk201doesntexist View Post
@op, Thanks, but at least, check the howtos you link to, there's missing steps there.
I dont agree these kind of threads should be in dev section.
Why? It's great for people to learn.

Sent from my Galaxy Nexus using xda premium
 
PaulW21781
Old
#7  
Senior Member
Thanks Meter 60
Posts: 333
Join Date: Jan 2006
Location: Northwich
Quote:
Originally Posted by ljwnow View Post
Why? It's great for people to learn.

Sent from my Galaxy Nexus using xda premium
Agreed, the thing which fuels development is curiosity, and when people want to know how to do something, it helps to have links or topics dedicated to that specific area.

The OP's link is pretty much the same as this too (official Android building guide)

http://source.android.com/source/initializing.html
Phones (all S-OFF & Rooted): HTC Desire AMOLED PVT1 (Oxygen R2 HBOOT) -=- HTC Wildfire -=- HTC DesireHD -=- Nexus S -=- Galaxy Nexus
 
dave_t321
Old
#8  
Member
Thanks Meter 25
Posts: 58
Join Date: Jul 2010
Has anyone managed to build the android-4.0.1_r1.2 branch with Ubuntu 11.10?

I know it works on the master branch and the r1 branch supposedly didn't support it but have the build tools been updated this one?

Just wanted to check before commiting to a massive download!
 
shenye
Old
#9  
shenye's Avatar
Retired Forum Moderator / Recognized Developer - OP
Thanks Meter 1303
Posts: 488
Join Date: Oct 2009
Location: London

 
DONATE TO ME
Quote:
Originally Posted by dave_t321 View Post
Has anyone managed to build the android-4.0.1_r1.2 branch with Ubuntu 11.10?

I know it works on the master branch and the r1 branch supposedly didn't support it but have the build tools been updated this one?

Just wanted to check before commiting to a massive download!
It's the branch I use for building VillainROM.

Follow me on Twitter: @shen_ye
Circle me on Google+: google.com/+ShenYe
The Following User Says Thank You to shenye For This Useful Post: [ Click to Expand ]
 
PaulW21781
Old
#10  
Senior Member
Thanks Meter 60
Posts: 333
Join Date: Jan 2006
Location: Northwich
Quote:
Originally Posted by dave_t321 View Post
Has anyone managed to build the android-4.0.1_r1.2 branch with Ubuntu 11.10?

I know it works on the master branch and the r1 branch supposedly didn't support it but have the build tools been updated this one?

Just wanted to check before commiting to a massive download!
The only thing to note with 11.10, is when you install all the build libraries, one of them is incorrect (no longer available in 11.10). Instead of installing lib32readline5-dev you need to install lib32readline-dev instead.

Code:
Select Code
$ sudo apt-get install git-core gnupg flex bison gperf build-essential \
  zip curl zlib1g-dev libc6-dev lib32ncurses5-dev ia32-libs \
  x11proto-core-dev libx11-dev lib32readline-dev lib32z-dev \
  libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown \
  libxml2-utils
Phones (all S-OFF & Rooted): HTC Desire AMOLED PVT1 (Oxygen R2 HBOOT) -=- HTC Wildfire -=- HTC DesireHD -=- Nexus S -=- Galaxy Nexus

The Following 4 Users Say Thank You to PaulW21781 For This Useful Post: [ Click to Expand ]
Tags
compile ics maguro aosp
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes