windows 如何下载Android的谷歌源代码

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7047902/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 17:50:24  来源:igfitidea点击:

How to download google source code for android

androidpythonwindowsgitandroid-source

提问by Jon

As you know, there is a list of several hundred projects in https://android.googlesource.com/. I'd like to download them all in windows machine. According to Google's document,

如您所知,https://android.googlesource.com/中有数百个项目的列表。我想将它们全部下载到 Windows 机器中。根据谷歌的文件,

To install, initialize, and configure Repo:

$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo


To clone the entire platform, install repo, and run:

mkdir mydroid
cd mydroid
repo init -u https://android.googlesource.com/platform/manifest
repo sync

In my machine, however, I cannot "repo init" in Git Bash because it says it does not have python. I have python installed but git bash does not recognize it. Note that I set the python directory to the system path too.If anybody can give a tip, I would appreciate it. Thanks

但是,在我的机器中,我无法在 Git Bash 中“repo init”,因为它说它没有 python。我安装了 python,但 git bash 无法识别它。请注意,我也将 python 目录设置为系统路径。如果有人可以提供提示,我将不胜感激。谢谢

UPDATE: I believe it's problem with new version of Git Bash for Windows. System path is not applied to Git Bash at all - I could easily test if system path worked with command prompt. Anyway, I tried this instead and it actually ran with error of course.

更新:我相信新版本的 Git Bash for Windows 有问题。系统路径根本不适用于 Git Bash - 我可以轻松测试系统路径是否与命令提示符一起工作。无论如何,我尝试了这个,当然它实际上运行时出错了。

  /c/python27/python.exe  ../bin/repo init -u https://android.googlesource.com/platform/manifest

The error message is

错误信息是

 $ /c/python27/python.exe ../bin/repo init -u https://android.googlesource.com/platform/manifest
 Traceback (most recent call last):
   File "../bin/repo", line 91, in <module>
    import readline
 ImportError: No module named readline

OK. I passed this error by installing pyreadline in windows:

好的。我通过在 Windows 中安装 pyreadline 传递了这个错误:

 easy_install pyreadline

If you got an error, you must install setuptools from

如果出现错误,则必须从以下位置安装 setuptools

 http://pypi.python.org/pypi/setuptools#files

And finally ran the command again to get this:

最后再次运行命令得到这个:

$ repo init -u https://android.googlesource.com/platform/manifest
fatal: unable to start d:\mywork\dev\GoogleAndroid\working_dir\.repo\repo/main.py
fatal: [Errno 8] Exec format error

回答by Mohammad Ersan

With one click, download the latest code as .tar.gzfile, from here https://android.googlesource.com/platform/frameworks/base/+archive/master.tar.gz, the android could be found under corefolder

随着点击,下载最新的代码.tar.gz文件,从这里 https://android.googlesource.com/platform/frameworks/base/+archive/master.tar.gz,Android的可能下找到core文件夹

Edit
Alternative here:
http://grepcode.com/project/repository.grepcode.com/java/ext/com.google.android/android/


在此处编辑替代方案:http:
//grepcode.com/project/repository.grepcode.com/java/ext/com.google.android/android/

Just select the version then a download options within.

只需选择版本,然后选择其中的下载选项。

回答by VonC

If you consider, as an example, this other program "sympy"which also needs git bash and python, it is only a matter to add python to your PATH priorto launching the git bash session.

例如,如果您考虑另一个程序“sympy”,它也需要 git bash 和 python,那么只需启动 git bash 会话之前将 python 添加到您的 PATH即可。

Install Python from:

从以下位置安装 Python:

http://python.org/download/

http://python.org/download/

by downloading the "Python 2.7 Windows installer" (or Python 2.6 or 2.5) and running it.
Add python directory to your system environment path variable
(My Computer -> Advanced -> Environment Variables -> Path -> Edit).

通过下载“Python 2.7 Windows 安装程序”(或 Python 2.6 或 2.5)并运行它。
将 python 目录添加到您的系统环境路径变量
( My Computer -> Advanced -> Environment Variables -> Path -> Edit)。

Note that the repo script itself must be in the path, as mentioned in the Version Control pageof android:

请注意,repo 脚本本身必须在路径中,如android的版本控制页面中所述:

Repo is a repository management tool that we built on top of Git. Repo unifies the many Git repositories when necessary, does the uploads to our revision control system, and automates parts of the Android development workflow.
Repo is not meant to replace Git, only to make it easier to work with Git in the context of Android.
The repo command is an executable Python script that you can put anywhere in your path.

Repo 是我们构建在 Git 之上的存储库管理工具。Repo 在必要时统一了许多 Git 存储库,上传到我们的版本控制系统,并自动化部分 Android 开发工作流程。
Repo 并不是要取代 Git,只是为了让在 Android 环境中使用 Git 更容易。
repo 命令是一个可执行的 Python 脚本,您可以将其放在路径中的任何位置

回答by olibre

This answer explains how to fix this error:

这个答案解释了如何修复这个错误:

fatal: unable to start c:\path\.repo\repo/main.py
fatal: [Errno 8] Exec format error

Summary:I finally used the pythonpackaged by Cygwin.
Details:Below is the full story.

总结:我终于使用了pythonCygwin 打包的。
详细信息:以下是完整的故事。

The tip from the repobug trackingis to add '/c/app/Python27/python ':

错误跟踪提示repo是添加'/c/app/Python27/python '

  • line 136 in v1.20
    REPO_MAIN = '/c/app/Python27/python ' + S_repo + '/main.py'
  • line 735 in v1.20 (beginning of function main)
    wrapper_path = '/c/app/Python27/python ' + os.path.abspath(__file__)
  • v1.20 中的第 136 行
    REPO_MAIN = '/c/app/Python27/python ' + S_repo + '/main.py'
  • v1.20 中的第 735 行(函数开头main
    wrapper_path = '/c/app/Python27/python ' + os.path.abspath(__file__)

But we get the error TypeError: coercing to Unicode: need string or buffer, NoneType found

但是我们得到了错误 TypeError: coercing to Unicode: need string or buffer, NoneType found

Therefore I reverted these changes above and performed the other changes below (on version 1.20):

因此,我恢复了上面的这些更改并执行了下面的其他更改(在 1.20 版上):

  • line 136, replaced single slash by double back-slash:
    REPO_MAIN = S_repo + '\\main.py'
  • line 766, added pythonabsolute path as first element of me:
    me = ['C:\\app\\Python27\\python.exe', repo_main,
    '--repo-dir=%s' % rel_repo_dir,
    '--wrapper-version=%s' % ver_str,
    '--wrapper-path=%s' % wrapper_path,
    '--']
  • line 776, replaced os.execv(repo_main, me)by
    os.execv('C:\\app\\Python27\\python.exe', me)
  • 第 136 行,用双反斜线替换单斜线:
    REPO_MAIN = S_repo + '\\main.py'
  • 第 766 行,添加了python绝对路径作为第一个元素me
    me = ['C:\\app\\Python27\\python.exe', repo_main,
    '--repo-dir=%s' % rel_repo_dir,
    '--wrapper-version=%s' % ver_str,
    '--wrapper-path=%s' % wrapper_path,
    '--']
  • 第 776 行,替换os.execv(repo_main, me)
    os.execv('C:\\app\\Python27\\python.exe', me)

However we get still an error:

但是我们仍然得到一个错误:

$ Traceback (most recent call last):
  File "c:\path\.repo\repo\main.py", line 39, in <module>
    from subcmds.version import Version
  File "c:\path\.repo\repo\subcmds\__init__.py", line 36, in <module>
    ['%s' % name])
  File "c:\path\.repo\repo\subcmds\forall.py", line 17, in <module>
    import fcntl
ImportError: No module named fcntl

The Python v2.7 fcntldocumentationsays fcntlis available for platform Unix only.

Python的V2.7fcntl文件说,fcntl仅适用于Unix的平台。

I finally reverted again all changes in reposcript and installed Cygwin including its pythonand gitpackages: it succeeded as a charm.

我终于再次恢复了repo脚本中的所有更改并安装了 Cygwin,包括它的pythongit包:它成功了。

But, as the symlinkssimulated by Cygwin are not recognized by the MSysGit, we have to use the Cygwin git. And GUIs on top of gitare not fully compliant with Cygwin git...

但是,由于Cygwin 模拟的符号链接不被 MSysGit 识别,我们必须使用 Cygwin git。并且顶部的 GUIgit不完全符合 Cygwin git......

(see also my other post)

(另见我的另一篇文章

Edit:
Cygwin can use native NTFS symlinks(just set CYGWIN=winsymlinks:nativeand be Admin). Therefore MSysGit can be used and any other GUI based on it :-)

编辑:
Cygwin 可以使用本机 NTFS 符号链接(只需设置CYGWIN=winsymlinks:native并成为管理员)。因此可以使用 MSysGit 和基于它的任何其他 GUI :-)