Quantcast
Channel: xda-developers - Android Software and Hacking General [Developers Only]
Viewing all articles
Browse latest Browse all 3614

[ULTIMATE GUIDE] [A-Z] Using Android Source Code/ How to Compile

$
0
0
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

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)
The list goes on and on. You should get used to these because you are going to be using them a lot (assuming you will actually give back to the community ;)).

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
This command also needs to be run on Ubuntu 12.04(.2):
Quote:

sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
Secondly, the Android SDK is needed:
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"
Run the command 'android' to check for updates. The Android SDK is now installed!

Last thing to do is run:
Quote:

gksudo gedit /etc/udev/rules.d/51-android.rules
and add this:
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"

Save it and run:
Quote:

sudo chmod a+r /etc/udev/rules.d/51-android.rules
Wow. We done alot there... what did we do?
  1. First, we downloaded the packages that we need to compile android.
  2. Secondly, we installed the Android SDK. This gives us adb, fastboot etc. We will go into detail about this later.
  3. Last of all, we added in vendor IDs for USB to make sure connecting to our devices works.

Viewing all articles
Browse latest Browse all 3614

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>