最近一直在尝试下android 源码的下载,昨天晚上折腾了好久,终于成功了。其实,主要就是怎么解决googleFQ的问题。最终在网上看到的方法,就是不适用google的地址,而是从其他的网站上获取源码。现在记录下方法如下:
1.在自己的主目录下创建bin目录,添加到环境变量中。
mkdir ~/bin PATH=~/bin:$PATH(添加环境变量) chmod a+x ~/bin
2.根据网上提供的方法,我们获取google的repo(这个应该是服务器地址)
(1)curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo(repo 成功) (2)repo init -u https://android.googlesource.com/platform/manifest -b android-5.1.1_r9(进行repo操作)
这个方法失败了,提示如下
fatal: Cannot get https://gerrit.googlesource.com/git-repo/clone.bundle fatal: error [Errno 101] Network is unreachable
看起来是因为网络需要FQ。网上寻找其他方法
3.获取其他服务器上的repo地址
git clone git://aosp.tuna.tsinghua.edu.cn/android/git-repo.git/(这个应该是获取一个网站上的信息集合,得到一个git-repo文件夹)
4.将步骤三中获得的repo放到~/bin目录下
~/bin中去 cp repo ~/bin/
5.更改repo下的uri如下
REPO_URL = ‘git://aosp.tuna.tsinghua.edu.cn/android/git-repo‘
6.在代码文件夹中进行repo仓库拷贝
repo init -u git://aosp.tuna.tsinghua.edu.cn/android/platform/manifest
执行到这一步的时候,出现了如下的问题:
Run git config --global user.email "you@example.com" git config --global user.name "Your Name" to set your account‘s default identity. Omit --global to set the identity only in this repository. fatal: unable to auto-detect email address (got ‘zhangshuli@zhangshuli.(none)‘)
这里是让我们增加一个邮箱,我们只需要按照上面的命令提示,增加一下邮箱跟个人信息就够了。不过,这个东西似乎可以随便写的,应该只有你需要向服务器上传东西的时候,才会用到的(比如通知一些信息等)
git config --global user.email "1554525476@qq.com" git config --global user.name "zhangshuli"
7.最后我们使用一个脚本来执行repo sync操作
比我我创建的脚本名称是zsl_repo.sh
内容如下
export PATH=~/bin:$PATH repo sync -j2 if [ "$?" != "0" ]; then sleep 30 repo sync -j2 fi
然后我们运行sh zsl_repo.sh就可以了
这个方法最终成功的获得了源码
上述方法参考自http://blog.csdn.net/sunao2002002/article/details/47869281
原文:http://www.cnblogs.com/zhangshuli-1989/p/zsl_2016_3_20_11_17.html