- Sep 13, 2011
- 776
- 102
- 0
WHERE DO ROMs COME FROM?
-
I built Android from source once. Once. Haven't done it since, but I've been itchin' to. Real bad. I mean, what's better than seeing your own name printed in one lonely section of the system settings, which no one's going to see unless you show them? I'll tell you: Nothing. Nothing is better. Seriously though, building Android from source is surely the zenith of Android customization. Follow along with me as I fail repeatedly, and completely misunderstand what I'm supposed to be doing. I'm going to document every step I take along the way. All I ask of you is that you correct me when I'm wrong, because I will be, and lead me to better practices if you know any, because you likely know more than I do.-
** DISCLAIMER **I don't know what I'm doing. I'm serious. I've done research, I've asked questions, and what I'm telling you worked for me (hopefully). That, by no means, guarantees that it will work for you. Be careful. I barely know my way around Linux. I took a Linux systems administration course about 3 years ago, but I've only used it on and off since then for various reasons. This means that some of the things I do will be blindly following the direction of others. If you're following along at home, do some additional research on your own. Some of the steps I take may end up being superfluous, or even unintentionally malign. These errors will be corrected as I find them by my own research, or as I am made aware of them by others. Underlying point of all of this: I'm going to make mistakes. Please be careful not to make the same mistakes as me.
SO, HOW DO WE GET STARTED?
I. SETTING UP THE BUILD ENVIRONMENT
There are so many different Linux distributions to choose from, but the choice, for me, was pretty easy. Since my goal is to build Android from source, I need a distribution that is likely to have the most number of users who have tried to do the same. The more attempts to build on a particular OS, the more likely it is that there's a forum thread or blog article addressing whatever issue I might run into. DistroWatch gives me some idea of the number of users on any particular distribution, and the top two are Mint and Ubuntu. Seeing that Mint is based on Ubuntu, and that it uses the Ubuntu repositories, it follows that most of the forum topics and blog posts are going to be in terms of Ubuntu. I'm going to try to use the current release, 13.04. Once the OS is done, there's still a lot of software that needs to be installed in order to build. I'm following the build environment setup instructions given in this thread on XDA: [GUIDE] How to Configure Ubuntu 13.04 Raring Ringtail for Compiling Android ROMs.
- Install OS
Download Ubuntu: Download Ubuntu Desktop (Make sure to get the 64-bit version)
NOTE: If you want to try to build on a 32-bit machine, here's a link to some instructions, which I have not tried myself, but may help you to get that going: Building latest AOSP 4.2.2_r1 from source, using 32 bit Ubuntu 12.04
Make a bootable USB-Drive/DVD-ROM: I used the Universal USB Installer to make a bootable flash drive.
Reboot.
Boot off of the flash drive/DVD-ROM.
Follow the on-screen instructions to install Ubuntu alongside Windows.
- - Install JDK
First, we need to add the correct repository.
There's going to be lots of terminal use here, so if you're not that familiar with using the terminal, here's a cheat sheet for you: Linux Terminal Command Reference
Open a terminal and type the following and press enter:
Code:sudo add-apt-repository ppa:webupd8team/java
This repository will allow you to perform the next step.
Now type this into the terminal, followed by enter:
Code:sudo apt-get update && sudo apt-get install oracle-java6-installer
If you'd like to check, you can enter the following command in order to display your current version of Java:
Code:java -version
This was the output I got from the command:
Code:java version "1.6.0_45" Java(TM) SE Runtime Environment (build 1.6.0_45-b06) Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)
NOTE: For those of you who might already have OpenJDK installed, I've read that it can be a pain to work with when compiling Android. I have not successfully built a ROM using OpenJDK. That does not mean that it is not possible. I believe that EarthnFire78 uses OpenJDK for building his ROMs, but I'm not positive. Point is, if you wish to follow these instructions precisely as laid out here, your gonna want to stick with Oracle's version of the JDK. Here's a command to remove OpenJDK if you already have it installed:
Code:sudo apt-get purge openjdk-\* icedtea-\* icedtea6-\*
- Install the Build Dependencies
You can copy and paste the following long command into the terminal and then press enter:
Code:sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev zlib1g-dev:i386 libc6-dev lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev:i386 libreadline6-dev:i386 lib32z-dev libgl1-mesa-glx:i386 libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown libxml2-utils xsltproc readline-common libreadline6-dev libreadline6 lib32readline-gplv2-dev libncurses5-dev lib32readline5 lib32readline6 libreadline-dev libreadline6-dev:i386 libreadline6:i386 bzip2 libbz2-dev libbz2-1.0 libghc-bzlib-dev lib32bz2-dev libsdl1.2-dev libesd0-dev squashfs-tools pngcrush schedtool libwxgtk2.8-dev python
This command took about 35 minutes to complete on my box.
Here's a list of all the individual components you need to install, for reference:
[TABLE="width: 500, align: left"]
[TR]
[TD]git-core[/TD]
[TD]gnupg[/TD]
[TD]flex[/TD]
[/TR]
[TR]
[TD]bison[/TD]
[TD]gperf[/TD]
[TD]build-essential[/TD]
[/TR]
[TR]
[TD]zip[/TD]
[TD]curl[/TD]
[TD]zlib1g-dev[/TD]
[/TR]
[TR]
[TD]zlib1g-dev:i386[/TD]
[TD]libc6-dev[/TD]
[TD]lib32ncurses5-dev[/TD]
[/TR]
[TR]
[TD]ia32-libs[/TD]
[TD]x11proto-core-dev[/TD]
[TD]libx11-dev:i386[/TD]
[/TR]
[TR]
[TD]libreadline6-dev:i386[/TD]
[TD]lib32z-dev[/TD]
[TD]libgl1-mesa-glx:i386[/TD]
[/TR]
[TR]
[TD]libgl1-mesa-dev[/TD]
[TD]g++-multilib[/TD]
[TD]mingw32[/TD]
[/TR]
[TR]
[TD]tofrodos[/TD]
[TD]python-markdown[/TD]
[TD]libxml2-utils[/TD]
[/TR]
[TR]
[TD]xsltproc[/TD]
[TD]readline-common[/TD]
[TD]libreadline6-dev[/TD]
[/TR]
[TR]
[TD]libreadline6[/TD]
[TD]lib32readline-gplv2-dev[/TD]
[TD]libncurses5-dev[/TD]
[/TR]
[TR]
[TD]lib32readline5[/TD]
[TD]lib32readline6[/TD]
[TD]libreadline-dev[/TD]
[/TR]
[TR]
[TD]libreadline6-dev:i386[/TD]
[TD]libreadline6:i386[/TD]
[TD]bzip2[/TD]
[/TR]
[TR]
[TD]libbz2-dev[/TD]
[TD]libbz2-1.0[/TD]
[TD]libghc-bzlib-dev[/TD]
[/TR]
[TR]
[TD]lib32bz2-dev[/TD]
[TD]libsdl1.2-dev[/TD]
[TD]libesd0-dev[/TD]
[/TR]
[TR]
[TD]squashfs-tools[/TD]
[TD]pngcrush[/TD]
[TD]schedtool[/TD]
[/TR]
[TR]
[TD]libwxgtk2.8-dev[/TD]
[TD]python[/TD]
[TD][/TD]
[/TR]
[/TABLE]
Then, create a symbolic link to /usr/lib/i386-linux-gnu/mesa/libGL.so.1 by entering the following into the terminal:
Code:sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
- Setup Repo and Sync with a Repository
Next step, make a new directory, download repo to it, and then make repo executable. All of that can be done with the following command. Type or copy and paste it and press enter:
Code:mkdir ~/bin && curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo && chmod a+x ~/bin/repo
The next step is to add ~/bin to your path variable. To edit it in terminal, type the following and execute:
Code:sudo nano ~/.bashrc
To do it in a GUI editor, do the following instead:
Code:sudo gedit ~/.bashrc
Whichever method you're comfortable with will work, they both have the same effect. Once you have ~/.bashrc open in either nano or gedit (or whatever editor you like), add the following line to the very bottom:
Code:export PATH=~/bin:$PATH
If you omit this last step, when you go to execute repo init, you'll get an error like the following:
Code:No command 'repo' found, did you mean: Command 'repl' from package 'mailutils-mh' (universe) Command 'repl' from package 'nmh' (universe) Command 'repro' from package 'repro' (universe) Command 'rep' from package 'rep' (universe) repo: command not found
Now that you've edited ~/.bashrc, save it and close it.
Type the following command to make those changes apply to the current terminal session:
Code:source ~/.bashrc
At this point, your system is setup to build any (I think) recent branch of Android. The instructions that follow will be specific to Gingerbread, but following that will be instructions on what needs to be done differently for Ice Cream Sandwich or Jelly Bean.
Time to make a directory to hold all the source files you're about to download. Find a location, generally in your home folder, or a subdirectory of your home folder. Here, I'm going to make a directory called 'android' in my home folder. I'll do that with the following command:
Code:[COLOR=#222225]mkdir ~/android/gingerbread[/COLOR]
Now that we've made a place to save the source, let's move to it, and use repo to download all the source code for the particular branch I'm going to build. For this first attempt, I'll try Gingerbread. The repo I'm going to use is Superior Irken Organs (thanks to Earthnfire78!). To begin, we need to setup the email address and name for git, so enter the following:
Code:git config --global user.email "you@example.com" git config --global user.name "Your Name"
Git is now configured, so let's download the source! Move to the directory you created for the source code, and repo init, then sync. Modify the -j option as depending on the number of cores your processor has. I've seen -j16 recommended for an 8 core processor, so you'd probably want to use a lower number if you have less cores. I went with -j16, but I'm not sure if that helped or hurt me:
Code:[COLOR=#222225]cd ~/android/gingerbread [/COLOR][COLOR=#222225]repo init -u git://github.com/SuperiorIrkenOrgans/android.git -b gingerbread [/COLOR]repo sync -j6
- - Build It!
This it it! Time to build that ROM. This is also generally where things start to get sticky. I ran into a problem here that I hope none of you have to contend with, but with the help of the community, it was sorted out. I'll go over the required commands, and then describe the problem I encountered, and how to fix it. If anyone else has problems, post about it in this thread, and if a solution is found, I'll add it to the list of possible problems.
So here we go. Start by ensuring you're in the directory you created to store the source:
Code:cd ~/android/gingerbread
After you're sure you're in the right directory, execute the following commands:
Code:source build/envsetup.sh
Last edited: