| <html devsite><head> |
| <title>源代码同步问题</title> |
| <meta name="project_path" value="/_project.yaml"/> |
| <meta name="book_path" value="/_book.yaml"/> |
| </head> |
| <body> |
| <!-- |
| Copyright 2017 The Android Open Source Project |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| --> |
| |
| <p>尽管我们一直万分谨慎,但 Android 源代码有时还是会出现一些小问题。本页详细介绍了您在尝试同步 Android 源代码时可能会遇到的一些已知问题。 |
| |
| </p><h2 id="difficulties-syncing-the-source-code-proxy-issues"> |
| 同步源代码时遇到的问题(代理问题)</h2> |
| <p><strong>症状</strong>:<code>repo init</code> 或 <code>repo sync</code> 失败,并显示 HTTP 错误,通常为 403 或 500。</p> |
| <p><strong>原因</strong>:有很多可能的原因,大多数情况下都与 HTTP 代理有关,这些代理无法顺利传输大量数据。</p> |
| <p><strong>解决方法</strong>:虽然还没有通用的解决方法,但有人报告说使用 Python 2.7 以及明确使用 <code>repo sync -j1</code> 可以改善某些用户的情况。</p> |
| |
| <h2 id="difficulties-syncing-the-source-tree-dns-issues"> |
| 同步源代码树时遇到的问题(DNS 问题)</h2> |
| <p><strong>症状</strong>:在运行 <code>repo sync</code> 时进程失败,并显示与无法识别主机名相关的各种错误。其中一种错误是 <code><urlopen error [Errno -2] Name or service not known></code>。</p> |
| <p><strong>原因</strong>:有些 DNS 系统难以应对同步源代码树时涉及的大量查询(在最糟糕的情况下,可能会有数百条查询请求)。</p> |
| <p><strong>解决方法</strong>:手动解析相关主机名,并在本地对解析结果进行硬编码。</p> |
| <p>您可以使用 <code>nslookup</code> 命令解析主机名,该命令将为每个主机名指定一个数字 IP 地址(通常是在输出的“Address”(地址)部分)。</p> |
| <pre class="devsite-click-to-copy"> |
| <code class="devsite-terminal">nslookup googlesource.com</code> |
| <code class="devsite-terminal">nslookup android.googlesource.com</code> |
| </pre> |
| <p>然后,您可以在本地对它们进行硬编码,方法是修改 <code>/etc/hosts</code>,在该文件中添加两行内容,形式如下:</p> |
| <pre class="devsite-click-to-copy"> |
| aaa.bbb.ccc.ddd googlesource.com |
| eee.fff.ggg.hhh android.googlesource.com |
| </pre> |
| <p>请注意,这种方法只适用于服务器的地址不会更改的情况;如果服务器的地址发生更改,导致您无法连接,那么您必须重新解析这些主机名,并相应地修改 <code>etc/hosts</code>。</p> |
| |
| <h2 id="difficulties-syncing-the-source-tree-tcp-issues"> |
| 同步源代码树时遇到的问题(TCP 问题)</h2> |
| <p><strong>症状</strong>:在同步时 <code>repo sync</code> 挂起,通常是在同步操作完成 99% 时出现这种情况。</p> |
| <p><strong>原因</strong>:TCP/IP 堆栈中的某些设置在有些网络环境中会导致出现问题,使得 <code>repo sync</code> 既无法完成,也不会失败。</p> |
| <p><strong>解决方法</strong>:在 Linux 中,请输入以下命令:</p> |
| <pre class="devsite-terminal devsite-click-to-copy">sysctl -w net.ipv4.tcp_window_scaling=0</pre> |
| <p>在 MacOS 中,请在网络设置部分停用 rfc1323 扩展程序。</p> |
| |
| </body></html> |