windows环境下载Android源码

通过在window平台上安装 cygwin来模拟Linux环境来下载Android源码。
1.1、安装cygwin.
直接在cygwin官网下载
注意在安装 Cygwin 时,我们除了安装默认的组件,我们还需要安装 bash, curl, git and python
1.2、添加path路径
编辑.bash_profile添加path路径。. bash_profile 文件位于“ %cygwin安装目录%\home\%用户% ”这个目录。比如我的就是“ D:\tools\cygwin\home\rohu
.bash_profile 文件中追加一行
export PATH=~/bin:$PATH
如果在国内,需要代理才能出去。 如果用代理的话,还需要加上一个句命令。
假设代理服务器为“ 127.0.0.2::8080 ”,则命令为:
export http_proxy=127.0.0.2:8080
1.3、安装repo
通过 Cygwin 菜单 Cygwin Terminal 进入shell命令行。
输入以下命令:
mkdir ~/bin
curl   --insecure   https://dl-ssl.google.com/dl/googlesource/git-repo/repo  >  ~/bin/repo
chmod a+x ~/bin/repo
如果在国内,需要代理才能出去。假设代理服务器为“ 127.0.0.2::8080
如果用代理的话,上面的命令就应该变为:
mkdir ~/bin
curl   --insecure   --proxy  127.0.0.2:8080   https://dl-ssl.google.com/dl/googlesource/git-repo/repo  >  ~/bin/repo
chmod a+x ~/bin/repo
到此repo脚本文件就安装好了。
1.4、配置git
shell命令行,输入以下命令:
git  config  --global http.sslverify "false"
如果在国内,需要代理才能出去。 如果用代理的话,还需要加上一个句命令。
假设代理服务器为“ 127.0.0.2::8080 ”,则命令为:
git   config  --global http.proxy " 127.0.0.2:8080"
到此git就配置好了。
1.5、安装repo客服端
1.5.1、新建一个工作目录 WORKING_DIRECTORY,切换到该目录,以便存放Android源码:
在shell命令行,输入以下命令:
$ mkdir WORKING_DIRECTORY $ cd WORKING_DIRECTORY
15.2、 Run repo init to bring down the latest version of Repo with all its most recent bug fixes. You must specify a URL for the manifest, which specifies where the various repositories included in the Android source will be placed within your working directory.
$ repo init -u https://android.googlesource.com/platform/manifest 

To check out a branch other than "master", specify it with -b:

$ repo init -u https://android.googlesource.com/platform/manifest -b android-4.4.4_r2.0.1
1.5.3、 When prompted, please configure Repo with your real name and email address. To use the Gerrit code-review tool, you will need an email address that is connected with a registered Google account. Make sure this is a live address at which you can receive messages. The name that you provide here will show up in attributions for your code submissions.在运行1.5.2的命令时,会弹出一个要求输入你的gmail邮箱的提示。最好输入有效的邮箱地址。
A successful initialization will end with a message stating that Repo is initialized in your working directory. Your client directory should now contain a .repo directory where files such as the manifest will be kept.
在repo完成初始化后,你再当前目录下,应该能看到一个".repo"目录,manifest等就在该目录下。
如果你在这步遇到gpg验证出错,抛异常。那么请修改~/bin/repo文件的第187行来跳过gpg验证。
如下:
    if _NeedSetupGnuPG():
       can_verify = False 
    else:
      can_verify = True
另外,我们可以通过在浏览器中输入 https://android.googlesource.com/platform/manifest来获得各个版本对应的branch
这里贴出来,具体看最下面。
1.6、取得源码

To pull down files to your working directory from the repositories as specified in the default manifest, run

$ repo sync 

The Android source files will be located in your working directory under their project names. The initial sync operation will take an hour or more to complete.

执行上面的命令,Android的源码就开始下载了,它将被下载到" .repo "目录的" projects "目录下。
下载过程可能会弹出错误:fatal: '../platform/abi/cpp.git' does not appear to be a git repository
解决方法:在.repo目录下的找到fetch属性改成 fetch="git://Android.git.linaro.org/"
1.7、下载kernel源码
执行以下命令
git clone https://android.googlesource.com/kernel/common.git
将在Android目录下看到一个 common 目录,得到的 common 里面看不到文件,只有 .git 目录
进入common再执行 git branch -a 得到
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/android-2.6.39
  remotes/origin/android-3.0
  remotes/origin/master
这时我们可以通过执行 git checkout android-3.0 得到 kernel3.0 源码 同样,
同理同过执行 git checkout android-2.6.39 将得到 kernel2.6.39 源码



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值