准备工作:
装一个Ubuntu系统(http://www.ubuntu.com/download/desktop)
ps:( ubuntu装完后把系统软件全都更新一下)
一个翻墙vpn(https://www.cloudtizi.com/guides/ubuntu_pptp)
下载环境搭建:
访问: http://source.android.com/source/initializing.html
Installing the JDK:
$ sudo apt-get update
$ sudo apt-get install openjdk-7-jdk
$ sudo update-alternatives --config java
$ sudo update-alternatives --config javac
Installing required packages:(安装各种编译工具)
$ sudo apt-get install git gnupg flex bison gperf build-essential \
zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev \
libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 \
libgl1-mesa-dev g++-multilib mingw32 tofrodos \
python-markdown libxml2-utils xsltproc zlib1g-dev:i386
$ sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
Configuring USB Access:(配置usb访问)
$ wget -S -O - http://source.android.com/source/51-android.rules | sed "s/<username>/$USER/" |sudo tee >/dev/null /etc/udev/rules.d/51-android.rules;
sudo udevadm control --reload-rules
Installing Repo安装repo(repo是git的管理工具)
$ mkdir ~/bin
$ PATH=~/bin:$PATH
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
installing Repo client初始化repo
$ mkdir WORKING_DIRECTORY
$ cd WORKING_DIRECTORY
$ repo init -u https://android.googlesource.com/platform/manifest
$ repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1
(你要同步的源码的tag)
Downloading the Android Source Tree同步源码
$ repo sync
这个命令如果代理断了需要重新执行这个命令同步代码
当控制台显示 successful的时候恭喜你代码同步成功了
下载硬件驱动(非常必要)
访问https://developers.google.com/android/nexus/drivers
根据你Nexus 7 (Wi-Fi) binaries for Android 5.0.1 (LRX22C)下载源码的tag下载相关的驱动
具体步骤参考http://my.oschina.net/547217475/blog/548852
Building the System编译源码(一两个小时)
进入你的源码目录
$ source build/envsetup.sh
or
$ . build/envsetup.sh
Choose which target 选择你要编译的版本
$ lunch
$ make -j4
安装linux版的sdk并配置成环境变量
步骤如下:
1,查询当前sdk的路径:比如我的/home/xxx/android-sdks
2,
sudo gedit /etc/profile
在文件末尾添加
PATH=$PATH:/home/xxx/android-sdks/tools:/home/xxx/android-sdks/platform-tools
3,通过命令生效
. /etc/profile
Flash a Device进行刷机模式连接你的要刷的机器
$ adb reboot bootloader
Once the device is in fastboot mode, run 刷机
$ fastboot flashall -w
来源:oschina
链接:https://my.oschina.net/u/159896/blog/548994