[INFO]Table of Contents
[/INFO]
Android is known for its ability to be customized by the end user. The typical way to do this is to flash a rom, which is essentially an "image" of the operating system plus other goodies that can give you entirely new look and a host of neat features to play with. But rom developers usually start at one point--"source."
Source is essentially the raw code of Android. Let's put it this way--if you want to make an omelete, you're going to have get some eggs, cheese, spices, etc. Those ingredients are source. You put those ingredients together and you get an omelet, or at least get you something close enough. Here's how we get to that point.
[WARN]This guide is primarily for users of Ubuntu, particularly 64 bit. I will frequently use and mention several other guides that can help you if you are on other operating systems, particularly Mac OSX (check out the AOSP one first). If you are unfamiliar with Ubuntu/Linux, I advise you to read up a bit and become at least "moderately" familiar with how it works, particularly terminal and sudo/"root" permission commands.
Further, make sure you have enough space and adequate hardware to do this. I've seen recommendations of having at least a dualcore machine, with 2+ gb of RAM and at least 25-30 gigs of harddrive space free. Builds take up quite a lot of space, so you want to play it safe![/WARN]
The first step in compiling Android is to create what's called a "build environment." Essentially, you're installing a bunch of software that will enable you to both sync up ("download") the source and to actually put together either flashable images or a flashable zip.
It is always best to have the Android SDK installed on your machine. Go here to download the SDK package, extract it, and put it in your "home" directory. Be sure to follow the instructions and ensure everything is working properly. It's also good to triple-check that fastboot and ADB are both functional and usable.
[TIP]A great guide to installing the SDK and other neat Android goodies can be found here. I personally used it and it was awesome.[/TIP].
Now let's get to to installing more important stuff. The first thing on the list is the JDK (Java 6), since that's the JDK required for compiling Gingerbread and all of the Android versions after. Obviously most of you will want to compile Jelly Bean, so this is crucial.
The recommended way to do this is to open up the terminal and type in these commands. Note, you can copy and paste the command (copy from "sudo" until the end) and make sure hit enter after each command!
If for some reasons that does not work, there are some alternatives, notably this:
If that does not work, and it may not due to licensing and support issues, either (1) Google search the issue by copying/pasting the command line error into Google (wrap it in quotes!), or (2) try to search for other alternatives repositories to add. We have several options in the fourth post (troubleshooting/fixes) as well as a few that have been mentioned throughout this guide. This is a bit of a wonky step, so don't let it get you down! Not your fault, just blame Google/Sun
.
Once the JDK is installed, you need to install Python. In some versions of Ubuntu (and I believe 12.04 is one of those versions, Python is already installed. Still, it doesn't hurt to double check!
Simply enter this command:
Git is one of the coolest, yet most confusing things, about Android/Linux. Think of it this way--it's a place where all of the revisions to the code go to be approved and get incorporated so that you have a solid piece of working software.
For git, enter this:
Once the JDK, python, and git are installed, you're ready to start installing some more "specific" packages required to compile Android.
If you're running Ubuntu (remember, 64 bit), and your version of Ubuntu is between 10.04 and 11.10, simply input this entire thing and hit enter:
If you're on Ubuntu 10.10, also input this:
If you're on Ubuntu 11.10, you want to input this:
You may also need this if you're on 11.10, so I'd recommend installing it anyway (and this may be duplicative, but don't worry, Ubuntu's smarter than she may sometime act!)
If you're like me and you're on Ubuntu 12.04 (again, 64 bit!), there are two warnings that Google/Android gives us: (1) building on 12.04 is experimental, and (2) it's not guaranteed to work for any branch of the repository other than the master branch.
That being said, here are your packages:
And don't forget this...
This step is important because it will enable to access pretty much any Android device by using your USB port (and your USB cable). First, let's bring up the file you'll need to "edit":
This will open up a text file. In that file, simply copy and paste this big ole list right into it, save it, and then close the file.
Remember, be sure to save it and close it. Once closed, enter this command:
Now your build environment is complete and you're ready to download the repo/source and get crackin'. If you have any issues, I suggest checking out my sources as well as simply asking me/our community or Googling the issue. The best way to search for an error (that I have found) is to simply copy and paste the "error" from your terminal into Google and seeing what comes out. Adding in extra terms like "Android" "source" "compile" and "build" may also help.
[NOTE]I'd like to give credit where it's due, and that's mainly these following five resources--Android Open Source Project, XDA Developer dastin1015, NPRussell, futurecrue, and droseum20. Thanks to all of these great guides and devs![/NOTE]
[/INFO]
Android is known for its ability to be customized by the end user. The typical way to do this is to flash a rom, which is essentially an "image" of the operating system plus other goodies that can give you entirely new look and a host of neat features to play with. But rom developers usually start at one point--"source."
Source is essentially the raw code of Android. Let's put it this way--if you want to make an omelete, you're going to have get some eggs, cheese, spices, etc. Those ingredients are source. You put those ingredients together and you get an omelet, or at least get you something close enough. Here's how we get to that point.
[WARN]This guide is primarily for users of Ubuntu, particularly 64 bit. I will frequently use and mention several other guides that can help you if you are on other operating systems, particularly Mac OSX (check out the AOSP one first). If you are unfamiliar with Ubuntu/Linux, I advise you to read up a bit and become at least "moderately" familiar with how it works, particularly terminal and sudo/"root" permission commands.
Further, make sure you have enough space and adequate hardware to do this. I've seen recommendations of having at least a dualcore machine, with 2+ gb of RAM and at least 25-30 gigs of harddrive space free. Builds take up quite a lot of space, so you want to play it safe![/WARN]
The first step in compiling Android is to create what's called a "build environment." Essentially, you're installing a bunch of software that will enable you to both sync up ("download") the source and to actually put together either flashable images or a flashable zip.
#1 Install the Android SDK
It is always best to have the Android SDK installed on your machine. Go here to download the SDK package, extract it, and put it in your "home" directory. Be sure to follow the instructions and ensure everything is working properly. It's also good to triple-check that fastboot and ADB are both functional and usable.
[TIP]A great guide to installing the SDK and other neat Android goodies can be found here. I personally used it and it was awesome.[/TIP].
#2 Install the Java Development Kit (JDK/Java 6)
Now let's get to to installing more important stuff. The first thing on the list is the JDK (Java 6), since that's the JDK required for compiling Gingerbread and all of the Android versions after. Obviously most of you will want to compile Jelly Bean, so this is crucial.
The recommended way to do this is to open up the terminal and type in these commands. Note, you can copy and paste the command (copy from "sudo" until the end) and make sure hit enter after each command!
$ sudo add-apt-repository "deb Index of / lucid partner"
$ sudo apt-get update
$ sudo apt-get install sun-java6-jdk
If for some reasons that does not work, there are some alternatives, notably this:
$ sudo apt-get install openjdk-6-jdk
If that does not work, and it may not due to licensing and support issues, either (1) Google search the issue by copying/pasting the command line error into Google (wrap it in quotes!), or (2) try to search for other alternatives repositories to add. We have several options in the fourth post (troubleshooting/fixes) as well as a few that have been mentioned throughout this guide. This is a bit of a wonky step, so don't let it get you down! Not your fault, just blame Google/Sun
#3 Install Python
Once the JDK is installed, you need to install Python. In some versions of Ubuntu (and I believe 12.04 is one of those versions, Python is already installed. Still, it doesn't hurt to double check!
Simply enter this command:
$ sudo apt-get install python
#4 Install Git
Git is one of the coolest, yet most confusing things, about Android/Linux. Think of it this way--it's a place where all of the revisions to the code go to be approved and get incorporated so that you have a solid piece of working software.
For git, enter this:
$ sudo apt-get install git-core
#5 Install the Required Packages
Once the JDK, python, and git are installed, you're ready to start installing some more "specific" packages required to compile Android.
If you're running Ubuntu (remember, 64 bit), and your version of Ubuntu is between 10.04 and 11.10, simply input this entire thing and hit enter:
$ 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
If you're on Ubuntu 10.10, also input this:
$ sudo ln -s /usr/lib32/mesa/libGL.so.1 /usr/lib32/mesa/libGL.so
If you're on Ubuntu 11.10, you want to input this:
$ sudo apt-get install libx11-dev:i386
You may also need this if you're on 11.10, so I'd recommend installing it anyway (and this may be duplicative, but don't worry, Ubuntu's smarter than she may sometime act!)
$ sudo ln -s /usr/lib/i386-linux-gnu/libX11.so.6 /usr/lib/i386-linux-gnu/libX11.so
If you're like me and you're on Ubuntu 12.04 (again, 64 bit!), there are two warnings that Google/Android gives us: (1) building on 12.04 is experimental, and (2) it's not guaranteed to work for any branch of the repository other than the master branch.
That being said, here are your packages:
$ sudo apt-get install git-core gnupg flex bison gperf build-essential \
zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev \
libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 \
libgl1-mesa-dev g++-multilib mingw32 openjdk-6-jdk tofrodos \
python-markdown libxml2-utils xsltproc zlib1g-dev:i386
And don't forget this...
$ sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
#6 Configure USB Access
This step is important because it will enable to access pretty much any Android device by using your USB port (and your USB cable). First, let's bring up the file you'll need to "edit":
$ gksudo gedit /etc/udev/rules.d/51-android.rules
This will open up a text file. In that file, simply copy and paste this big ole list right into it, save it, and then close the file.
#Acer
SUBSYSTEM=="usb", ATTR{idVendor}=="0502", MODE="0666"
#ASUS
SUBSYSTEM=="usb", ATTR{idVendor}=="0b05", MODE="0666"
#Dell
SUBSYSTEM=="usb", ATTR{idVendor}=="413c", MODE="0666"
#Foxconn
SUBSYSTEM=="usb", ATTR{idVendor}=="0489", MODE="0666"
#Garmin-Asus
SUBSYSTEM=="usb", ATTR{idVendor}=="091E", MODE="0666"
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", MODE="0666"
#HTC
SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", MODE="0666"
#Huawei
SUBSYSTEM=="usb", ATTR{idVendor}=="12d1", MODE="0666"
#K-Touch
SUBSYSTEM=="usb", ATTR{idVendor}=="24e3", MODE="0666"
#KT Tech
SUBSYSTEM=="usb", ATTR{idVendor}=="2116", MODE="0666"
#Kyocera
SUBSYSTEM=="usb", ATTR{idVendor}=="0482", MODE="0666"
#Lenevo
SUBSYSTEM=="usb", ATTR{idVendor}=="17EF", MODE="0666"
#LG
SUBSYSTEM=="usb", ATTR{idVendor}=="1004", MODE="0666"
#Motorola
SUBSYSTEM=="usb", ATTR{idVendor}=="22b8", MODE="0666"
#NEC
SUBSYSTEM=="usb", ATTR{idVendor}=="0409", MODE="0666"
#Nook
SUBSYSTEM=="usb", ATTR{idVendor}=="2080", MODE="0666"
#Nvidia
SUBSYSTEM=="usb", ATTR{idVendor}=="0955", MODE="0666"
#OTGV
SUBSYSTEM=="usb", ATTR{idVendor}=="2257", MODE="0666"
#Pantech
SUBSYSTEM=="usb", ATTR{idVendor}=="10A9", MODE="0666"
#Philips
SUBSYSTEM=="usb", ATTR{idVendor}=="0471", MODE="0666"
#PMC-Sierra
SUBSYSTEM=="usb", ATTR{idVendor}=="04da", MODE="0666"
#Qualcomm
SUBSYSTEM=="usb", ATTR{idVendor}=="05c6", MODE="0666"
#SK Telesys
SUBSYSTEM=="usb", ATTR{idVendor}=="1f53", MODE="0666"
#Samsung
SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", MODE="0666"
#Sharp
SUBSYSTEM=="usb", ATTR{idVendor}=="04dd", MODE="0666"
#Sony Ericsson
SUBSYSTEM=="usb", ATTR{idVendor}=="0fce", MODE="0666"
#Toshiba
SUBSYSTEM=="usb", ATTR{idVendor}=="0930", MODE="0666"
#ZTE
SUBSYSTEM=="usb", ATTR{idVendor}=="19D2", MODE="0666"
Remember, be sure to save it and close it. Once closed, enter this command:
$ sudo chmod a+r /etc/udev/rules.d/51-android.rules
Now your build environment is complete and you're ready to download the repo/source and get crackin'. If you have any issues, I suggest checking out my sources as well as simply asking me/our community or Googling the issue. The best way to search for an error (that I have found) is to simply copy and paste the "error" from your terminal into Google and seeing what comes out. Adding in extra terms like "Android" "source" "compile" and "build" may also help.
[NOTE]I'd like to give credit where it's due, and that's mainly these following five resources--Android Open Source Project, XDA Developer dastin1015, NPRussell, futurecrue, and droseum20. Thanks to all of these great guides and devs![/NOTE]
Last edited: