HOW-TO Compile ICS AOSP 4.0.3 (XOOM/GNEX/NEXUS S)

Jerry Hildenbrand

Space Cowboy
Staff member
Oct 11, 2009
5,577
2,816
113
Visit site
Prerequisites
An OEM unlocked Xoom (Verizon or US Wifi), Nexus S (any), Galaxy Nexus (Verizon or factory unlocked international only) A computer (ideally 64-bit multi-core and with 4GB RAM) with at least 50GB free disk space A working installation of Ubuntu 10.04LTS Basic computer skills and common sense Be aware that you may screw everything up and wreck your phone


Setting up the computer
There's a common myth that you need a super-computer to build Ice Cream Sandwich. That's simply not the case -- our own Beezy has built ICS on an ATOM powered netbook, it just takes a little longer. For example:
  • Quad-core i7 with 16GB RAM takes about 45 minutes
  • Six-core AMD with 16GB RAM takes about 45 minutes
  • Dual-core AMD with 8GB RAM takes about 120 minutes
  • MSI netbook with 1GB RAM takes about 30 hours
[INFO]The processor speed and number of cores is the big determining factor when it comes to build times. I have an old Blade server with 16 physical Xeon cores running at 1.8GHz and it takes about an hour -- longer than my 6 core AMD or Beezy's quad i7.

The next thing to consider is RAM. The more the better, but huge amounts of physical RAM are not the only way to go here. You'll need a big swap file if you don't have a lot of RAM. If you're setting up an older computer, don't be afraid to give it 16GB of swap. It's slower, but still works. If you don't give enough RAM/Swap you'll get errors. My machine has 16GB RAM and a 1GB swap file, but 4GB RAM and a 16GB swap file will work just fine.[/INFO]

You'll need to install Ubuntu 10.04LTS (64-bit) to follow this guide. Other set-ups will work (I use Slackware as well) but we're going to focus on using the system Google recommends -- because it works well. Set up your build computer with enough swap (see the info box above) and a good Internet connection. You can set up an SSH server and run a headless installation, or use a full blown desktop -- either works. Once you have the machine set-up and connected to the Internet, start installing the required packages. Open the terminal, and enter the following one line at a time. When prompted for any password, it wants your Ubuntu user password.

Installing the Sun JDK
You have to add an extra repository to install the Sun JDK. That's what the first two lines are doing -- adding the repo and initializing it.
Code:
sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
sudo apt-get update
sudo apt-get install sun-java6-jdk


Installing required packages
You'll need an assortment of utilities and tools to build AOSP. Install them from the command line by copying this and pasting (right click) it into your terminal.
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 lib32readline5-dev lib32z-dev libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown libxml2-utils xsltproc


Configure USB access
Normal users can't access the USB system by default. We're going to add in a set of rules that allows it. NEVER BUILD AOSP AS ROOT. Open nano (a terminal based text editor) with elevated permissions (we need to copy this file to the system as root) by typing the following at the command prompt:
Code:
sudo nano
Next comes some typing. Type these lines into the empty text file, being careful with spelling and syntax. When you see <username> in red, substitute your Ubuntu username (without brackets) instead.
Code:
# adb protocol on passion (Nexus One)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e12", MODE="0600", OWNER="[COLOR="Red"]<username>[/COLOR]"
# fastboot protocol on passion (Nexus One)
SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", ATTR{idProduct}=="0fff", MODE="0600", OWNER="[COLOR="red"]<username>[/COLOR]"
# adb protocol on crespo/crespo4g (Nexus S)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e22", MODE="0600", OWNER="[COLOR="red"]<username>[/COLOR]"
# fastboot protocol on crespo/crespo4g (Nexus S)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e20", MODE="0600", OWNER="[COLOR="red"]<username>[/COLOR]"
# adb protocol on stingray/wingray (Xoom)
SUBSYSTEM=="usb", ATTR{idVendor}=="22b8", ATTR{idProduct}=="70a9", MODE="0600", OWNER="[COLOR="red"]<username>[/COLOR]"
# fastboot protocol on stingray/wingray (Xoom)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="708c", MODE="0600", OWNER="[COLOR="red"]<username>[/COLOR]"
# adb protocol on maguro/toro (Galaxy Nexus)
SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0600", OWNER="[COLOR="red"]<username>[/COLOR]"
# fastboot protocol on maguro/toro (Galaxy Nexus)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e30", MODE="0600", OWNER="[COLOR="red"]<username>[/COLOR]"
# adb protocol on panda (PandaBoard)
SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d101", MODE="0600", OWNER="[COLOR="red"]<username>[/COLOR]"
# fastboot protocol on panda (PandaBoard)
SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d022", MODE="0600", OWNER="[COLOR="red"]<username>[/COLOR]"
When you've typed it all in and double-checked for errors, you want to save it. To save, press control+X, enter Y to save the file, then enter a file name and location. You need to use this for name and location:
Code:
/etc/udev/rules.d/51-android.rules
press enter and the file is saved.


Set up your .bashrc
the file /home/<username>/.bashrc is a resource file for the standard shell in Linux. Since it has a dot(.) as the first character, it's a hidden file. We need to edit it and add to your PATH (where the system looks automatically when you enter a file name). We'll use nano again, but this time we don;t need to be root because it's in our home folder. We're also creating a folder that we'll need later, but want to create it now so we can reference it in our .bashrc
Code:
mkdir ~/bin
nano -w ~/.bashrc
-w means we plan to write to this file, and the tilde (~) is a Linux shortcut to your home folder. Using the arrow keys scroll to the end of the file and add the following lines, remembering that <username> needs your Ubuntu username without the <> brackets.
Code:
export USE_CCACHE=1
export PATH=$PATH:/home/[COLOR="Red"]<username>[/COLOR]/bin
Save it like you did above -- control+x, then enter Y. You won't need to enter a file name, because it's already entered. Just hit the enter key. The first line allows the use of compilier cache, which speeds up build times. A lot. We want this. The second line puts ~/bin in your PATH, which we'll need in the next step. Once you have the file saved, we need to source our new .bashrc file. At the command line again:
Code:
source ~/.bashrc


Now your computer is all set up, ready to install the source code -- which we'll do in post #2
 
Last edited:

Jerry Hildenbrand

Space Cowboy
Staff member
Oct 11, 2009
5,577
2,816
113
Visit site
Re: HOW-TO Compile ICS AOSP (XOOM/GNEX/NEXUS S)

Getting the AOSP source

[INFO]This takes a while, and needs a solid Internet connection. You're going to be downloading a couple GB worth of source code. Get it started, then go read a book.[/INFO]

Install and initialize Repo
Repo is a program that lets you sync source code. Google keeps all the AOSP source online, and we can grab it with a few commands, but first we have to install the Repo program. At the terminal:
Code:
curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
chmod a+x ~/bin/repo
This puts the repo binary in ~/bin and marks it as an executable file (a program). Since we put ~/bin in our path, it's now available from any folder. Lets make a working folder and use it. Again, from the terminal:
Code:
cd ~
mkdir myAOSP
cd myAOSP
repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.3_r1
explanation of what you're doing, line by line:
  1. moving to your home folder
  2. making a new folder to place the source code in -- we're using myAOSP as the folder name
  3. downloading and initializing the manifest for Android 4.0.3 in our working folder
this will take just a few minutes, and you'll need to provide your name and a real e-mail address. Don't be stupid here, use your real name and e-mail -- Google has it anyway :p [INFO]Advanced users can edit this .repo script to only pull down only the files for their own device, but that's best left for another tutorial. If anyone wants to give this a try, holler.[/INFO]


Get the source
Three steps here. Downloading all the source, setting up a way to verify the source, and setting up CCACHE. All of it is done from the terminal (get used to it, you'll be using it a lot). To download your source code:
Code:
cd ~/myAOSP
repo sync
This is going to take a while -- it's a LOT of code. On an average Internet connection it takes 2-3 hours. On a 100MB synchronous fiber connection, it still takes an hour. You'll only have to sync everything once, though. When it's done, we want to set things up so we can verify the code later if we have to. From the terminal:
Code:
gpg --import
Then copy this entire block of text and paste it into the terminal
Code:
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.2.2 (GNU/Linux)

mQGiBEnnWD4RBACt9/h4v9xnnGDou13y3dvOx6/t43LPPIxeJ8eX9WB+8LLuROSV
lFhpHawsVAcFlmi7f7jdSRF+OvtZL9ShPKdLfwBJMNkU66/TZmPewS4m782ndtw7
8tR1cXb197Ob8kOfQB3A9yk2XZ4ei4ZC3i6wVdqHLRxABdncwu5hOF9KXwCgkxMD
u4PVgCha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c/KsjADtAuKW9/d8phb
N8bTyOJo856qg4oOEzKG9eeF7oaZTYBy33BTL0408sEBxiMior6b8LrZrAhkqDjA
vUXRwm/fFKgpsOysxC6xi553CxBUCH2omNV6Ka1LNMwzSp9ILz8jEGqmUtkBszwo
G1S8fXgE0Lq3cdDM/GJ4QXP/p6LiwNF99faDMTV3+2SAOGvytOX6KjKVzKOSsfJQ
hN0DlsIw8hqJc0WISQQYEQIACQUCSedYRAIbDAAKCRDorT+BmrEOeCUOAJ9qmR0l
EXzeoxcdoafxqf6gZlJZlACgkWF7wi2YLW3Oa+jv2QSTlrx4KLM=
=Wi5D
-----END PGP PUBLIC KEY BLOCK-----
Control + D saves the key and processes it. Now we can verify Git tags if we ever need to. Right now, we don't need to :) We DO need to finish setting up ccache. Back to the terminal and enter the following:
Code:
cd ~/myAOSP
prebuilt/linux-x86/ccache/ccache -M 50G

Adding proprietary binaries
We need a few pre-built files from the OEM added to our code. This step is a bit tricky, so read carefully. The files are different depending on what device you're building for. [INFO]Building for GSM Nexus S Download these files, and extract each of them into the ~/myAOSP folder Building for Sprint Nexus S Download these files, and extract each of them into the ~/myAOSP folder Building for Verizon XOOM Download these files, and extract each of them into the ~/myAOSP folder Building for Wifi XOOM Download these files, and extract each of them into the ~/myAOSP folder Building for GSM Galaxy Nexus Download these files, and extract each of them into the ~/myAOSP folder Building for Verizon Galaxy Nexus Download this file, and extract it into the ~/myAOSP folder [/INFO] Now you have some scripts extracted into the top level of your myAOSP folder. You'll need to run each of them. Do that from the terminal:
Code:
cd ~/myAOSP
./ [COLOR="Red"]<scriptname.sh>[/COLOR]
Replace <scriptname.sh> with the name of the script, without the <> brackets. You'll need to do this for each script so that proprietary drivers get installed for your hardware. Open the myAOSP folder in another terminal or file browser window to see the names of them all. [NOTE]If you have a Sprint Nexus S, you have one more step. Enter the following at the terminal:
Code:
cd ~/myAOSP
make signapk
it will run for a minute or two, and when it's finished:
Code:
cd ~/myAOSP
vendor/samsung/crespo4g/reassemble-apks.sh
[/NOTE] If any of this step confuses you, just ask. That's why we're all here.


Now we're ready to build :)
 
Last edited:

Jerry Hildenbrand

Space Cowboy
Staff member
Oct 11, 2009
5,577
2,816
113
Visit site
Re: HOW-TO Compile ICS AOSP (XOOM/GNEX/NEXUS S)

Building AOSP
This is what you've been waiting for :)

Clean things up
Clean everything up and get ready for building with the make clobber command. From the trusty terminal:
Code:
cd ~/myAOSP
make clobber
It will run for a minute or so, and when it's done everything is clean and ready for a new build.


Initialize and choose your target
There's a built in script to set all the temporary variables and PATH for building. You need to run it everytime you open a new session. Run it like so:
Code:
cd ~/myAOSP
source build/envsetup.sh
It will run for a bit, and then we're ready to choose our target with the lunch command. Back to the terminal, and enter:
Code:
lunch
You'll see a window like this:
attachment.php
You need to specify the target by entering the correct number. Here's a reference: [INFO]Verizon XOOM = stingray Wifi XOOM = wingray GSM Nexus S = crespo Sprint Nexus S = crespo4g GSM Galaxy Nexus = maguro Verizon Galaxy Nexus = toro[/INFO] Type in the correct number, then press enter. It will run for a bit, then return you to your prompt.

Build it
One last step, and that's the final build command. You'll need to know a little bit about your hardware here, specifically the number of CPU's you may have. In the following command, replace the * in -j* with the number of physical CPU cores you have times two. If you have a Quad core, use -j8. If you have a dual-core, use -j4. If you have dual quad-cores, use -j16. This tells the compiler how many threads to open, and time takes to enter it correctly saves build time and errors.
Code:
make otapackage -j*
Let it run, and run, and run. When it's finished, you'll have a flashable, deodexed zip file in home/<username>/myAOSP/out/target/product/<board name>/
attachment.php
Congrats :)
 
Last edited:

Andrew Ruffolo

Well-known member
Jan 5, 2010
3,567
172
0
Visit site
Awesome Jerry... now I'm going to be doing this my last 2 nights of work before 3 weeks of vacation. Wonder how long my Macbook with ubuntu virtual machine is going to take...
 

Andrew Ruffolo

Well-known member
Jan 5, 2010
3,567
172
0
Visit site
for the life of me, I can't figure out how to get the repo to sync on my macbook... no matter what version of ubuntu is running, it errors out or freezes.... so its building on my core i7 now... started 7:28pm eastern.
 

Paul627g

AC Moderator All-Star
Moderator
Nov 25, 2010
15,958
2,752
0
Visit site
Awesome Jerry.. I made one attempt at Ubuntu prior to ICS release trying to sync to the Cyanogen Mod repo but never got things setup properly because it would error out a step or two before syncing....

Can't wait to try this out and build ICS for my own kicks...
 

rufflez

Banned
Jan 5, 2010
122
19
0
Visit site
1) don't use a virtual machine... you will either have syncing issues with the repo or once you figure those out, compiling issues since you don't really have a swap partition
2) only use 10.04LTS -- newer versions of Ubuntu have a newer compiler version that has bugs when compiling android.

If you install 10.04LTS and follow this guide you should receive 0 errors.
 

fiznarp

New member
Feb 6, 2011
4
1
0
Visit site
Hello AOSP fans, did anyone else get this to build yet? I was able to successfully compile it and flash the 4.0.3_r1 tag to my LTE Galaxy Nexus. It boots up and connects to Wifi, however no cell service. It appears to be missing drivers for the LTE radio and possibly bluetooth.

Found this thread that describes how to pull the proprietary binaries from a stock LTE Nexus.

CDMA Binaries - xda-developers

So far I can't get this to work though... when I rebuild after running the extract script I get an image that causes my phone to get stuck at the Google logo.

Would be very interested to hear if anyone has gotten further.

Andrew
 
  • Like
Reactions: sephtin

sephtin

New member
Jan 20, 2011
1
0
0
Visit site
Thanks for the link for the proprietary binaries!

And I'm still building, but I know others have gotten it to work. When you installed, what did you wipe? To be safe, from CWR, data/cache/delvik/ ? .. might make a difference?
 

makeotapackage-j4

Well-known member
Jan 22, 2011
51
31
0
Visit site
You are a freaking saint Jerry!:D You have done waay better than any XDA tutorials I've seen. Thanks for taking the time to compose this- as it will help many.. "curious" members further understand AOSP, how it all works, and how to be more self-reliant in building the latest source.
God, I love Android Central.:)
 

JkdJedi

Well-known member
Aug 20, 2010
2,197
218
0
Visit site
Whats up guys, home alone so it's all about jumping into Ubuntu tonight for me, I'm following the XDA youtube vid and going the virtual drive route. I got Ubuntu installed (took this noob 2 hours for this, dam bios was not set for virtual visualization and my msconfig had my dual core cpu to just one!) anyway I'm stuck at updating,( # apt-get update) command. I'm getting a "Malformed line 54"....etc. (Having trouble copying/pasting any info from terminal to this thread) tahnks in advanced!!

jedi
 

Charles Dolly

OMFG!!!!!!
Aug 31, 2010
105
68
0
Visit site
Whats up guys, home alone so it's all about jumping into Ubuntu tonight for me, I'm following the XDA youtube vid and going the virtual drive route. I got Ubuntu installed (took this noob 2 hours for this, dam bios was not set for virtual visualization and my msconfig had my dual core cpu to just one!) anyway I'm stuck at updating,( # apt-get update) command. I'm getting a "Malformed line 54"....etc. (Having trouble copying/pasting any info from terminal to this thread) tahnks in advanced!!

jedi
If your following a guide from XDA you might want to go ask them, If however you want to follow this guide we would be glad to help. :)
 

JkdJedi

Well-known member
Aug 20, 2010
2,197
218
0
Visit site
1) don't use a virtual machine... you will either have syncing issues with the repo or once you figure those out, compiling issues since you don't really have a swap partition
2) only use 10.04LTS -- newer versions of Ubuntu have a newer compiler version that has bugs when compiling android.

If you install 10.04LTS and follow this guide you should receive 0 errors.

is it possible to install this with windows 7 in place or will I need to decide how bad I want ubuntu as my operating system?

Sent from my DROIDX using Tapatalk
 
  • Like
Reactions: Jerry Hildenbrand

Charles Dolly

OMFG!!!!!!
Aug 31, 2010
105
68
0
Visit site
is it possible to install this with windows 7 in place or will I need to decide how bad I want ubuntu as my operating system?

Sent from my DROIDX using Tapatalk
In case you didn't know you can install both Ubuntu and Windows 7 side by side so all you need to do is restart to boot one or the other :D Here is a guide Dual-Boot Windows 7 and Ubuntu in Perfect Harmony
 

Forum statistics

Threads
949,269
Messages
6,942,142
Members
3,161,414
Latest member
kuiperszone