Android OS Forum banner
1 - 20 of 3468 Posts

·
Premium Member
Joined
·
662 Posts
Build Environment
  • Linux based operating system -- Tested on Ubuntu 12.04, 12.10, 13.04 (64bit)
  • Terminal
  • Decent hardware (minimum of at least a dual core CPU and 4 GB of RAM)
  • Optimally have an SSD (standard mechanical drives work as well but slow down the process drastically)
  • Must have required packages for building installed, I will list them further down

Required Packages (based on Initializing a Build Environment)
Based on the version of Linux you run you might need to install slightly different packages. The following is for Ubuntu 12.04 and later:
Code:
sudo apt-get install git gnupg flex bison gperf build-essential \  zip curl libc6-dev [URL=libncurses5-dev:i386]libncurses5-dev:i386[/URL] x11proto-core-dev \  [URL=libx11-dev:i386]libx11-dev:i386[/URL] [URL=libreadline6-dev:i386]libreadline6-dev:i386[/URL] [URL=libgl1-mesa-glx:i386]libgl1-mesa-glx:i386[/URL] \  libgl1-mesa-dev g++-multilib mingw32 tofrodos \  python-markdown libxml2-utils xsltproc [URL=zlib1g-dev:i386]zlib1g-dev:i386[/URL] \  pngcrush schedtool
After installing the packages you need to create a symlink:
Code:
sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
IMPORTANT
It is recommended to build Android using the Oracle JDK 6. However it is no longer available as package in Ubuntu. A good source is http://www.webupd8.org
Code:
sudo add-apt-repository ppa:webupd8team/java
Code:
sudo apt-get update
Code:
sudo apt-get install oracle-java6-installer
Code:
sudo update-java-alternatives -s java-6-oracle
Code:
sudo apt-get install oracle-java6-set-default
Obtaining repo
Make directory for repo binary
Code:
mkdir ~/bin
Add directory for repo binary to your path
Code:
PATH=~/bin:$PATH
Download repo binary and place it in the proper directory
Code:
curl [URL=https://dl-ssl.google.com/dl/googlesource/git-repo/repo]https://dl-ssl.google.com/dl/googlesource/git-repo/repo[/URL] > ~/bin/repo
Give the repo binary the proper permissions
Code:
chmod a+x ~/bin/repo
Create directory for where the AOKP repo will be stored and synced
Code:
mkdir ~/aokp
Move to our new AOKP directory
Code:
cd ~/aokp
Download the source
Please read the AOSP building instructions before proceeding. Initialize
Code:
repo init -u [URL=https://github.com/AOKP/platform_manifest.git]https://github.com/AOKP/platform_manifest.git[/URL] -b jb-mr1
Run the following to sync the source
Code:
repo sync
Download the kernel source
Integrated kernel building is now required to compile AOKP for all supported devices (even Nexus devices!) From the root of your source tree, run the following script to grab the kernel sources required
Code:
. ./platform_manifest/manual_add_kernel_manifest.sh
Advanced users: Since the kernel trees are fairly large, you may want to sync only specific kernel trees for devices you build for, take a look at the file .repo/local_manifests/kernel_manifest.xml. You can edit this file to suite your needs.

Building
After the sync is finished, please read the instructions from the Android site on how to build.
Code:
. build/envsetup.shbrunch
You can also build (and see how long it took) for specific devices like this:
Code:
. build/envsetup.shtime brunch aokp_mako-userdebug
Remember to
Code:
make clobber
every now and then!

Setting up ccache (Optional)
You can optionally tell the build to use the ccache compilation tool. Ccache acts as a compiler cache that can be used to speed-up rebuilds. This works very well if you do "make clean" often, or if you frequently switch between different build products. Put the following in your .bashrc or equivalent.
Code:
export USE_CCACHE=1
By default the cache will be stored in ~/.ccache. If your home directory is on NFS or some other non-local filesystem, you will want to specify the directory in your .bashrc as well.
Code:
export CCACHE_DIR=
The suggested cache size is 50-100GB. You will need to run the following command once you have downloaded the source code:
Code:
. prebuilts/misc/linux-x86/ccache/ccache -M 50G
This setting is stored in the CCACHE_DIR and is persistent.
 

·
Good at breaking things
Joined
·
723 Posts
Thanks for this! I've been stumbling through making some builds over the past few days which seems to be working (after adapting a variety of different tutorials and a bit of guesswork). This confirms I'm on the right path!

One issue I've repeatedly run into... all my builds seem to be missing /system/etc/audio_policy.conf, which makes all audio go over the speaker no matter what. Any hints on what I may be messing up?

And finally... for repeating builds, I assume all that is necessary is:

Code:
<br />
cd ~/aokp_jb<br />
make clobber<br />
repo sync<br />
. build/envsetup.sh && brunch <target>
I read some on source.android.com about enabling CCACHE, but that doesn't appear (to my n00b eyes) to be an option when building AOKP - is this correct?

Thanks again!

... one more thing: I had been using "lunch" followed by "make otapackage" to build; now trying using "brunch maguro" I get a notice that "schedtool" is not installed. No biggie to install, just wondering if I missed something along the way.
 

·
Premium Member
Joined
·
662 Posts
Discussion Starter · #5 ·
Thanks for this! I've been stumbling through making some builds over the past few days which seems to be working (after adapting a variety of different tutorials and a bit of guesswork). This confirms I'm on the right path!

One issue I've repeatedly run into... all my builds seem to be missing /system/etc/audio_policy.conf, which makes all audio go over the speaker no matter what. Any hints on what I may be messing up?

And finally... for repeating builds, I assume all that is necessary is:

Code:
<br />
cd ~/aokp_jb<br />
make clobber<br />
repo sync<br />
. build/envsetup.sh && brunch <target>
I read some on source.android.com about enabling CCACHE, but that doesn't appear (to my n00b eyes) to be an option when building AOKP - is this correct?

Thanks again!

... one more thing: I had been using "lunch" followed by "make otapackage" to build; now trying using "brunch maguro" I get a notice that "schedtool" is not installed. No biggie to install, just wondering if I missed something along the way.
For the audio policy config file, that is usually pulled in via your device tree. Might want to take a look at that.

For CCACHE, all AOSP flavors can use it.

For schedutil, just run
Code:
sudo apt-get install schedutil pngcrush
 

·
Good at breaking things
Joined
·
723 Posts
For the audio policy config file, that is usually pulled in via your device tree. Might want to take a look at that.

For CCACHE, all AOSP flavors can use it.

For schedutil, just run
Code:
sudo apt-get install schedutil pngcrush
Thanks again for the help. I'm doing my best to learn this, but there just seem to be a few things that don't quite match up (maybe just in my mind). I'm eternally grateful to those who go out of their way to help me help myself :)

For the device tree, does that refer to the ~/aokp_jb/device directory tree, or is it something else? I have confirmed that ~/aokp_jb/device/samsung/tuna/audio/audio_policy.conf does exist. What else should I check? In the meantime, manually copying that file over to /system/etc/ after flashing my build seems to work fine so it's not a huge huge issue.

And thanks for the info on ccache. I guess I was stumped a bit since it didn't seem to exist under prebuilt/linux-x86/ccache as specified in the source.android.com documentation. Found it at prebuilts/misc/linux-x86/ccache though, so I'll give that a go for my next build.
 

·
Good at breaking things
Joined
·
723 Posts
Ohh nevermind, thats basically that last command at the bottom of your post correct?
Correct. Apparently the "brunch" command combines the "lunch" command (which effectively specifies the build target - that is, the device the build will be for) with the "make otapackage" command, which actually kicks off the compiling.

I think. I'm also king n00b.
 

·
Registered
Joined
·
4 Posts
For the audio policy config file, that is usually pulled in via your device tree. Might want to take a look at that.

For CCACHE, all AOSP flavors can use it.

For schedutil, just run
Code:
sudo apt-get install schedutil pngcrush
For me, I ran
Code:
sudo apt-get install schedtool
instead of schedutil running 12.04 if it makes a difference.
 

·
Good at breaking things
Joined
·
723 Posts
For me, I ran
Code:
sudo apt-get install schedtool
instead of schedutil running 12.04 if it makes a difference.
Me too. I wonder if schedtool is a piece of schedutil perhaps? *shrug* Just installing schedtool was enough to make brunch seem happy.

I was at least able to locate schedtool on https://launchpad.net/ubuntu/precise/+package/schedtool; couldn't find any results for schedutil. *shrug*
 

·
Registered
Joined
·
4 Posts
Me too. I wonder if schedtool is a piece of schedutil perhaps? *shrug* Just installing schedtool was enough to make brunch seem happy.

I was at least able to locate schedtool on https://launchpad.ne...ckage/schedtool; couldn't find any results for schedutil. *shrug*
It could be just the install candidate on ubuntu, maybe a forked and updated package or something. It was suggested by the buildscript and seems like it does pacify it. Toro is building right now so I'll check out the audio.conf bug and report on that when it finishes.
 

·
Registered
Joined
·
6 Posts
Thanks a lot for this guide! I've managed to build my very 1st bleeding edge AOKP rom for maguro!

Now two little questions:
- How do I actually make cherry-picks? I've seen some guides, but I'm a little confused that when I make a cherry-pick, the next time I won't have a clean code when I do the "repo sync".
- And is it possible to change the build info before I compile the actual ROM?

Thanks a lot again!
 

·
Good at breaking things
Joined
·
723 Posts
Thanks a lot for this guide! I've managed to build my very 1st bleeding edge AOKP rom for maguro!

Now two little questions:
- How do I actually make cherry-picks? I've seen some guides, but I'm a little confused that when I make a cherry-pick, the next time I won't have a clean code when I do the "repo sync".
I found a good rough guide on cherry-picking over here.

Essentially,
  • Hit up http://gerrit.sudose...status:eek:pen,n,z and find the commit you want. I'm a fan of I36f11787, "Use prebuilt su and supersu.apk"
  • Scroll down to the last patch and click the cherry-pick tab next to Download. Click the clipboard button at the far right to copy that command.
  • Scroll back up and look what Project the commit is under - in this case, AOKP/vendor_aokp.
  • Navigate (in terminal) to that part of your source tree - in my case, ~/aokp_jb/vendor/aokp.
  • Paste the command and hit Enter.
  • Your cherry has been picked! Build that shit!
Each time you repo sync, (I believe) your source tree gets restructured to mirror the merged commits - your cherry-picks will go away, so you have to re-pick each cherry anytime you resync. I think.

- And is it possible to change the build info before I compile the actual ROM?

Thanks a lot again!
I'm also curious on this. I'm sure it's possible, just haven't found the file(s) that need changing.
 

·
Registered
Joined
·
6 Posts
Thanks a lot codesplice!

That's great info! But the next time that I use "repo sync" my cherry-picks will be lost? (that's what I'm hoping for, since I dunno nothing about coding and I'm unable to find where that cherry went). Bottom line is, are the cherry-picks deleted everytime I do a sync.
Sorry for that, I guess we were writing at the same time

And I read about the audio bug when building, I had the same problem here with maguro. I just need to manually copy the file and it's done? How did you find the missing file? You know the whole tree by head? I read about people using qgit to visually manage branches and missing files but I couldn't make it work :)

I'm deeply sorry about all those questions, but one little more
. After I've built the ROM, I've extracted the zip, edited the build.prop and repacked the zip, then my ROM was unflashable, is this commom?

Thanks a lot!
 

·
Good at breaking things
Joined
·
723 Posts
Thanks a lot codesplice!

That's great info! But the next time that I use "repo sync" my cherry-picks will be lost? (that's what I'm hoping for, since I dunno nothing about coding and I'm unable to find where that cherry went). Bottom line is, are the cherry-picks deleted everytime I do a sync.
Sorry for that, I guess we were writing at the same time

And I read about the audio bug when building, I had the same problem here with maguro. I just need to manually copy the file and it's done? How did you find the missing file? You know the whole tree by head? I read about people using qgit to visually manage branches and missing files but I couldn't make it work :)

I'm deeply sorry about all those questions, but one little more
. After I've built the ROM, I've extracted the zip, edited the build.prop and repacked the zip, then my ROM was unflashable, is this commom?

Thanks a lot!
I haven't had good results trying to manually repackage the zip (what method were you using?). I've been able to manually pull the audio_policy.conf file from ~/aokp_jb/device/samsung/tuna/audio; I then adb push it to /system/etc after flashing the ROM. That works for me (so far).
 

·
Premium Member
Joined
·
662 Posts
For me, I ran
Code:
sudo apt-get install schedtool
instead of schedutil running 12.04 if it makes a difference.
pngcrush is needed for optimizations that are done with brunch at the end of the compile.

Also, schedtool is the correct package, will update.
 

·
Registered
Joined
·
6 Posts
@codesplice

Oh i'll try to use the adb push command then, I was using winrar (yup you can laugh :)). Thanks a lot for your help, I'll look around and see if I can find how to change the build info before compiling the ROM, I'll reply back if I find anything.

Thanks!
 

·
Registered
Joined
·
4 Posts
pngcrush is needed for optimizations that are done with brunch at the end of the compile.

Also, schedtool is the correct package, will update.
glad I saw your previous post before I started building then! Thanks for the guide and the help!
 
1 - 20 of 3468 Posts
Top