如何在 Windows 操作系统中查看 Android 源代码?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2746407/
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
How can I check out Android source code in Windows OS?
提问by RobGThai
I try to search for it but I just cant. I am running Windows 7 on Lenovo G460 laptop. I tried to install Ubuntu on it but I cannot use Wireless to connect to the internet for some reason.
我试图搜索它,但我不能。我在联想 G460 笔记本电脑上运行 Windows 7。我尝试在其上安装 Ubuntu,但由于某种原因无法使用无线连接到互联网。
Is there anyway for me to get a look at Android source code or at least just the Calendar part of it?
无论如何让我看看Android源代码或至少只是它的日历部分?
回答by poke
You can browse the android source code using their repository browser. If you want to check out a specific project (i.e. download the source), you will need to get the version control system Git. When you have Git running, you can either clone a complete repository using git clone https://android.googlesource.com/projectname.git
or just get the HEAD (the most current version of all files, useful if you only want to browse through the source) by doing git clone --depth 1 https://android.googlesource.com/projectname.git
.
您可以使用他们的存储库浏览器浏览 android 源代码。如果要查看特定项目(即下载源代码),则需要获取版本控制系统Git。当你的Git运行,您可以使用克隆一个完整的信息库git clone https://android.googlesource.com/projectname.git
或刚拿到HEAD(所有文件的最新版本,有用的,如果你只是想通过源浏览)做git clone --depth 1 https://android.googlesource.com/projectname.git
。
The project name is the top folderyou select on the repository browser, for example platform/packages/apps/Calendar
for the Calendar app. Then the full command is git clone https://android.googlesource.com/platform/packages/apps/Calendar
.
项目名称是您在存储库浏览器上选择的顶级文件夹,例如platform/packages/apps/Calendar
日历应用程序。那么完整的命令是git clone https://android.googlesource.com/platform/packages/apps/Calendar
.
回答by hotshot309
The GitWeb and Google Code Search repositories for Android have been retired since this question was originally answered. Fortunately, the SDK Manager finally allows you to download the source codefor Android 4.0 and lateralong with all of the APIs and tools.
自从最初回答这个问题以来,Android 的 GitWeb 和 Google 代码搜索存储库已停用。幸运的是,SDK 管理器最终允许您下载Android 4.0 及更高版本的源代码以及所有 API 和工具。
If you need access to pre-Ice Cream Sandwich (4.0) Android source code and don't want to use Google's non-Windows download instructions, you can search GrepCodefor what you need online. (Look for "android" and the name of the class or method you want, and then pick the version of the code you want.) GrepCode works, but I have seen it crash IE a bunch of times. An alternative would be to download the Android Sources plugin for Eclipse, which gives you all of the source code for versions of Android up to 4.0.1.
如果您需要访问pre-Ice Cream Sandwich (4.0) Android 源代码并且不想使用Google 的非Windows 下载说明,您可以在线搜索GrepCode以获取所需内容。(查找“android”和您想要的类或方法的名称,然后选择您想要的代码版本。) GrepCode 可以工作,但我已经看到它使 IE 崩溃了很多次。另一种方法是下载Eclipse的Android Sources 插件,它为您提供了 Android 4.0.1 版本之前的所有源代码。
Once you have the source code, you can attach the source directory you are using to your .jar in Eclipse, as follows:
获得源代码后,您可以将正在使用的源目录附加到 Eclipse 中的 .jar,如下所示:
Right-click the project > Properties> Java Build Path> Librariestab > select the +beside the .jar you want to attach source code to > click on Source Attachmentto edit the path to where the source files reside.
右键单击项目 >属性> Java 构建路径>库选项卡 > 选择要将源代码附加到的 .jar 旁边的+> 单击源附件以编辑源文件所在的路径。
回答by sayyed mohsen zahraee
Steps:
脚步:
- Download Cygwin from http://cygwin.com/install.html.
- Install cygwin with almost all defaults. During cygwin setup, select modules
curl
andpython
(search for them) and mark them to be installed. Start cygwin.exe and go to your preferred directory (mine is
D:/Android/sources/4.0/try2
). Example:$: cd /cygdrive/d/Android/sources/4.0/try2
Run the below instructions one by one:
i)
mkdir bin
ii)
PATH=/cygdrive/d/Android/sources/4.0/try2/bin:$PATH
iii)
curl https://storage.googleapis.com/git-repo-downloads/repo > /cygdrive/d/Android/sources/4.0/try2/bin/repo
iv)
mkdir source
v)
cd source
vi)
Masterbranch:repo init -u https://android.googlesource.com/platform/manifest
4.0.1 branchfor example:
repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1
vii) Give credentials if needed
viii)
repo sync
- 从http://cygwin.com/install.html下载 Cygwin 。
- 使用几乎所有默认值安装 cygwin。在 cygwin 安装过程中,选择模块
curl
并python
(搜索它们)并将它们标记为要安装。 启动 cygwin.exe 并转到您的首选目录(我的是
D:/Android/sources/4.0/try2
)。例子:$: cd /cygdrive/d/Android/sources/4.0/try2
一一运行以下说明:
一世)
mkdir bin
ii)
PATH=/cygdrive/d/Android/sources/4.0/try2/bin:$PATH
三)
curl https://storage.googleapis.com/git-repo-downloads/repo > /cygdrive/d/Android/sources/4.0/try2/bin/repo
iv)
mkdir source
v)
cd source
vi)
主分支:repo init -u https://android.googlesource.com/platform/manifest
以 4.0.1 分支为例:
repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1
vii) 如果需要,提供凭据
八)
repo sync
Source: click here
来源:点击这里
回答by karthikeyan m
Thanks a lot, a quick guide on helping the download in windows, check this
非常感谢,帮助在 Windows 中下载的快速指南,检查这个
http://honey200.wordpress.com/2011/11/17/download-android-source-code-in-windows/
http://honey200.wordpress.com/2011/11/17/download-android-source-code-in-windows/
回答by Amir Saniyan
1) Install Git: http://git-scm.com/
1) 安装 Git: http://git-scm.com/
2) Open Git Bash
from Start Menu > Git > Git Bash
2)Git Bash
从开始菜单 > Git > Git Bash打开
3) In Git Bash window, change current directory to your favorite directory (For example D:\android_src) by following command: cd /d/androidsrc/
3) 在 Git Bash 窗口中,通过以下命令将当前目录更改为您喜欢的目录(例如 D:\android_src): cd /d/androidsrc/
4) In Windows Explorer, create an empty file D:\android_src\download.sh
and open it by notepad
4)在Windows资源管理器中,创建一个空文件D:\android_src\download.sh
并用记事本打开它
5) Open the following link and copy the code & paste it into D:\android_src\download.sh
, then save and close the notepad:
5) 打开以下链接,复制代码并粘贴到 中D:\android_src\download.sh
,然后保存并关闭记事本:
6) Execute download shell script in Git Bash window by following command: ./download.sh
6) 在 Git Bash 窗口中通过以下命令执行下载 shell 脚本: ./download.sh
See also:https://android.googlesource.com/
回答by James Moore
Install cygwin, and install the cygwin verion of git, then follow the normal instructions for installing repo.
安装cygwin,并安装 git 的 cygwin 版本,然后按照正常说明安装 repo。
You'll want to have git around anyway - it's become the standard vcsfor modern dev work. Some stuff is in svn still, but that's dying out.
无论如何你都会想要 git - 它已经成为现代开发工作的标准 vcs。有些东西仍然在 svn 中,但它正在消失。