编译Android源代码
本文介绍的是如何在linux环境下获取、编译源代码,并在编译之后运行。使用的操作系统为Ubuntu11.04
获取源代码
Android源代码仓库是分布式的,叫做GIT,所以在获取代码之前先安装git。Git与常用的svn,cvs不一样,但不必担心,android为了简化操作,使用phython脚本语言写了一个简化程序叫做curl。只需要按以下步骤一步一步操作就行了。
1. 安装git及curl
$ sudo apt-get install git-core curl
$ curl http://android.git.kernel.org./repo >~/repo
$ chmod a+x ~/repo $ mkdir android-source $ cd android-source
$ ~/repo init -u git://android.git.kernel.org/platform/manifest.git
REPO_URL='http://android.git.kernel.org/tools/repo.git'
$ ~/repo init -u http://android.git.kernel.org/platform/manifest.git
$ ~/repo init -u git://android.git.kernel.org/platform/manifest.git -b froyo
$ ~/repo sync
$ sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner" $ sudo add-apt-repository "deb-src http://archive.canonical.com/ubuntu lucid partner" $ sudo apt-get update $ sudo apt-get install sun-java6-jdk
$ sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu dapper main multiverse" $ sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu dapper-updates main multiverse" $ sudo apt-get update $ sudo apt-get install sun-java5-jdk
$ 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
$ sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev libc6-dev libncurses5-dev x11proto-core-dev libx11-dev libreadline5-dev libz-dev libgl1-mesa-dev
$ sudo apt-get install gcc-multilib g++-multilib libc6-i386 libc6-dev-i386
$ sudo apt-get install g++ g++-multilib
# adb protocol on passion (Nexus One) SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e12", MODE="0600", OWNER="<username>" # fastboot protocol on passion (Nexus One) SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", ATTR{idProduct}=="0fff", MODE="0600", OWNER="<username>" # adb protocol on crespo (Nexus S) SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e22", MODE="0600", OWNER="<username>" # fastboot protocol on crespo (Nexus S) SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e20", MODE="0600", OWNER="<username>"
$ source build/envsetup.sh
$ . build/envsetup.sh
$ lunch full-eng
$ make