Windows平台下载Android源码(整理)

Google官方下载源码使用的系统Ubuntu系统,不过现在我们需要在Windows系统中下载Android源码文件。

网站的地址是:https://android.googlesource.com/

里面包括Android系统各个部分的源码,我们只需要下载platform就行

点击进入即可看到下载地址

地址是:https://android.googlesource.com/platform/manifest

 1.准备工作

Android的源代码管理使用的是Git,所以安装Git必不可少,Windows系统中使用的是mysysgit目前的版本是Git-1.9.5-preview20150319.exe,自行搜索下载。源代码下载是使用Python脚本来完成的,所以还需要安装一个python环境。

 

2.下载XML描述文件

进入一个文件夹,用来存储XML描述文件,打开Git Bash执行如下命令

1
git clone https: //android .googlesource.com /platform/manifest

 不出意外的话很快就会下载完成,如果出现中断,请使用科学上网的方法重新下载,这里推荐一个乱炖hosts:http://levi.yii.so/archives/3553

下载完成后,执行如下命令:

1
git tag

 

选择相需要下载的版本,然后执行如下命令,检出相应的版本信息,这里已android-5.1.1_r8为例:

1
git checkout android-5.1.1_r8

 在default.xml文件中就定义了android源码的路径。

3.编写python脚本下载源码

文件内容如下,然后再进行具体解释:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import  xml.dom.minidom
import  os
from  subprocess  import  call
 
#downloaded source path
rootdir  =  "D:/Android/source/android-5.1.1_r8"
 
#git program path
git  =  "C:/Program Files (x86)/Git/bin/git.exe"
 
dom  =  xml.dom.minidom.parse( "D:/Android/source/manifest/default.xml" )
root  =  dom.documentElement
 
prefix  =  git  +  " clone https://android.googlesource.com/"
suffix  =  ".git"
 
if  not  os.path.exists(rootdir):
     os.mkdir(rootdir)
 
for  node  in  root.getElementsByTagName( "project" ):
     os.chdir(rootdir)
     =  node.getAttribute( "path" )
     last  =  d.rfind( "/" )
     if  last ! =  - 1 :
         =  rootdir  +  "/"  +  d[:last]
         if  not  os.path.exists(d):
             os.makedirs(d)
         os.chdir(d)
     cmd  =  prefix  +  node.getAttribute( "name" +  suffix
     call(cmd)

第6行:rootdir 表示源码的存储路径

第9行:git 表示git的安装路径

第11行:刚刚下载检出的default.xml文件路径

如果路径有不同的地方,根据自己的境况修改

最后一步就是执行这个python脚本进行下载,,,等着吧。。。

1
python download - src.py

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值