Get Android Source Code 20130702
http://source.android.com/source/downloading.html
1.Install REPO tool
1> Make sure you have a ~/bin/ directory in your home directory
$ mkdir ~/bin
2> Make sure that this bin directory is in your path
$ export PATH=~/bin:$PATH
$ echo $PATH
2.Install REPO tool (2/2)
1> Download REPO tool and make it executable:
$ curl http://android.git.kernel.org/repo >~/bin/repo
$ chmod a+x ~/bin/repo
3.Initializing a Repo client
1> Create an empty directory
$ mkdir WORKING_DIRECTORY
$ cd WORKING_DIRECTORY
4.Run repo init
$ repo init –u https://android.googlesource.com/platform/manifest -b android- 2.3.7_r1 (具体下载哪个版本根据个人需要)
5.Getting the files
$ repo sync
下载android代码过程中,提示以下错误:
error: Failed connect to android.googlesource.com:443;Connection refused while accessing https://android.googlesource.com/a/platform/frameworks/base/info/refs
fatal: HTTP request failed
解决方法:编辑/etc/hosts文件
$ vim /etc/hosts
增加下面内容,保存
74.125.31.82 www.googlesource.com
74.125.31.82 android.googlesource.com
203.208.46.172 cache.pack.google.com
59.24.3.173 cache.pack.google.com
然后重新输入
$ repo sync
可以继续下载了。我的android-4.1.1_r1前后下载了约8个小时.
在WORKING_DIRECTOR下直接make,编译了4.5h后出现
make: *** [out/target/common/obj/JAVA_LIBRARIES/ext_intermediates/classes-full-debug.jar] Error 41
20130718晚上,在原路径下执行命令make -j4后, 又编译了1.5个小时,没报错。
20130719上午继续make -j4,大约编译80分钟,编译完成。在out/target/product/generic下生成了system.img/ ramdisk.img/ userdata.img三个映像文件。
使用emulator命令,提示找不到命令。执行
$source build/envsetup.sh
$lunch full-eng
再输入命令emulator后,android-4.1.1仿真界面出现。证明编译ok.