Using Android Source Code/How to Compile
So you want to compile Android? It doesn't matter if it's AOSP, CyanogenMod, Paranoid Android or whatever - this will help.
Getting Started
So you want to compile Android? It doesn't matter if it's AOSP, CyanogenMod, Paranoid Android or whatever - this will help.
Getting Started
Intro
Android is great. It's fast, stable, easy to use.. oh, and it's open source. However, if you want to build your own versions - you'll need to learn a little bit.
Linux
Throughout this guide you will be using Linux, and if you don't even know what that is then please just stop now. If you do, well done! You're 1 step closer!
Git
Git is the project management software by the same person that made Linux, Linus Torvalds. It's really popular with open source devs so of course it is used with android! It's easy to use and is managed into repos. Repos also have branches which are mainly used for managing different versions of the code.
CyanogenMod
Ah, the great Cyanogen. Cyanogen was the man who kicked all this off! He created the ever so popular CyanogenMod ROM which helped speed up old devices. CyanogenMod has evolved into a worldwide project to help improve Android with after-market firmware and also provide materials for create these ROMs.
The Android Source Code
Google uploads all of it's Android source code to it's own git server into repos with specific names - here are some examples:
- Device Tree - android_device_*vendor*_*codename* (android_device_htc_shooteru for HTC Evo 3D)
- Kernel - android_kernel_*vendor*_*board* (android_kernel_htc_msm8660)
- Frameworks - android_frameworks_*part* (android_frameworks_av)
Requirements
Compiling Android is only possible on Linux 64-bit (typically) or maybe even OS X if you want a challenge. All the commands listed in this guide will be suited for Debian based distros (mainly Ubuntu), but if you have some experience with Linux, you can try changing them for use on other distros.
- Ubuntu 12.04(.2) or BBQLinux (not debian) running on your computer OR in VirtualBox
- At least 4GB of RAM
- Dual-Core is nice
- ~30GB of disk space for 1 project and a few builds
- A brain
- You will also need these packages installed:
Quote:
|
sudo apt-get install openjdk-6-jdk python git gnupg flex bison gperf build-essential \ zip curl libc6-dev libncurses5-dev x11proto-core-dev \ libx11-dev libreadline6-dev libgl1-mesa-glx \ libgl1-mesa-dev g++-multilib mingw32 tofrodos \ python-markdown libxml2-utils xsltproc zlib1g-dev |
Quote:
|
sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so |
- Download it: http://developer.android.com/sdk/index.html
- Extract the SDK in to your home directory
- Show hidden files and open .bashrc in your home directory. Add these at the bottom:
Code:
# Android tools
export PATH=${PATH}:~/android-sdk/tools
export PATH=${PATH}:~/android-sdk/platform-tools
export PATH=${PATH}:~/bin- Also add this to your .profile:
Code:
PATH="$HOME/android-sdk/tools:$HOME/android-sdk/platform-tools:$PATH"Last thing to do is run:
Quote:
|
gksudo gedit /etc/udev/rules.d/51-android.rules |
Code:
#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"
#Google
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"Quote:
|
sudo chmod a+r /etc/udev/rules.d/51-android.rules |
- First, we downloaded the packages that we need to compile android.
- Secondly, we installed the Android SDK. This gives us adb, fastboot etc. We will go into detail about this later.
- Last of all, we added in vendor IDs for USB to make sure connecting to our devices works.