Fork me on GitHub

【Android】Android 4.2源码下载(ubuntu 12.10)

【Android】Android 4.2源码下载(ubuntu 12.10)

前沿

    最近在研究NFC,这个不同在不同版本中API的使用都不同,想看下其源码实现,于是乎得重新下载下android源码了~~~

 

完整步骤

Installing some soft

1 Install curl:         sudo apt-get install curl

2 Install git-core:        sudo apt-get install git-core

 

Installing Repo

1 在用户目录下创建一个~/bin目录,并添加到环境变量中(要将git软件下载安装在此目录,在别的目录运行可能会找不到此软件,所以要添加到环境变量中)

$ mkdir ~/bin

$ PATH=~/bin:$PATH 

2 下载repo脚本并修改权限为可执行

$ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo

$ chmod a+x ~/bin/repo

  

Initializing a Repo client

1 创建一个保存android源码的目录,修改为最大权限,并进入到该目录下

$ mkdir /opt/android4.2

$ sudo chmod –R 777 /opt/android4.2

$ cd /opt/android4.2 

2 初始化repo,并选择要下载的分支(版本)

$ repo init -u https://android.googlesource.com/platform/manifest

$ repo init -u https://android.googlesource.com/platform/manifest -b android-4.2_r1

备注1:在这过程中需要输入你的姓名、邮箱等信息

备注2:查询android版本信息,参考 https://android.googlesource.com/platform/manifest/+refs

 

Getting the files

$ repo sync

 

问题

代码下载过程中,经常提示以下错误:

error: Failed connect to android.googlesource.com:443;Connection refused while accessinghttps://android.googlesource.com/a/platform/frameworks/base/info/refs

fatal: HTTP request failed

error: Cannot fetch platform/tools/motodev

error: Cannot fetch platform/frameworks/base

error: Cannot fetch platform/prebuilts/sdk

error: Exited sync due to fetch errors

解决方法:编辑/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.173cache.pack.google.com

然后重新输入

$ repo sync

 

 

 

Android4.2还算比较大,打包后大概9.5G左右,不打包14G左右

 

Ref:

1 Downloading the Source Tree: http://source.android.com/source/downloading.html

2 android4.2源码下载过程: http://blog.csdn.net/lengxibo/article/details/8299888#reply

http://zhu.im/Android/   非常好的一个链接,里面1.6到4.2各个版本都有,如果懒得自己下载就直接在此下载

 

 

posted @ 2013-02-26 19:12  SkySeraph  阅读(20704)  评论(5编辑  收藏  举报