中国大陆地区如何下载Android源码

strong text
bootable/recovery/ubootenv/uboot_env.c: In function ‘set_env_optarg’:
bootable/recovery/ubootenv/uboot_env.c:90:11: warning: assignment discards ‘const’ qualifier from pointer target type
value = optarg + strlen(name) + 1;
^
bootable/recovery/ubootenv/uboot_env.c:109:9: error: implicit declaration of function ‘free’ [-Werror=implicit-function-declaration]
free(buffer);
^
bootable/recovery/ubootenv/uboot_env.c:109:9: warning: incompatible implicit declaration of built-in function 'free’
cc1: some warnings being treated as errors
make: *** [out/target/product/generic_arm64/obj/STATIC_LIBRARIES/libenv_intermediates/uboot_env.o] 错误 1
make: *** 正在等待未完成的任务…

what happened?what should i do to deal with it ?

Seems that you come from China, So I will reply you in Chinese :wink:

你好,SMCXU:
目前你反馈的几个问题,描述都不太完整,最好一个问题可以在一个帖子里面回复(你之前已经有一个帖子关于编译问题的了)。

回到你的问题:

  • 需要提供完整的编译Log信息,就是从你敲make命令后的编译信息,都贴出来。
  • 目前来看,如下两个因素需要考虑:
    • 安装环境是否已经搭建完全
    • 目前Android SDK里面有部分仓库是直接从Google服务器下载的,由于你在中国大陆地区下载源码,如果没用VPN应该是下载不完全的,这个确认下是否已经下载完全。

谢谢!

1 Like

谢谢,目前为止,我感觉应该是源码下载不全,我再检查一下您提出的两点问题。

你好,请问可以不翻墙下载源码吗,我这边不太好翻墙,谢谢。

你好,我们近期会协助你解决这个问题,应该这个礼拜可以完成:有可能会在大陆搭建镜像服务器。

嗯,谢谢,请问在官网的辅助教程上能看到吗?

由于Android SDK的部分仓库需要从Google服务器下载,中国大陆地区用户,可以通过如下两种方式下载完整Android源码:

  • 使用VPN直接下载源码
    • 优点:直接下载,无需额外修改XML文件
    • 缺点:需要使用VPN,根据不同VPN提供商网速可能较慢
  • 使用内地镜像服务器下载
    • 优点:国内镜像服务器访问速度更快
    • 缺点:需要额外修改XML文件

VPN方式不再介绍,如下方法基于清华大学镜像服务器:

gouwa@Server:~/project/khadas/aosp/.repo/manifests$ git diff
diff --git a/default.xml b/default.xml
index f48a988..b8cb9da 100644
--- a/default.xml
+++ b/default.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <manifest>
-  <remote fetch="https://android.googlesource.com/" name="aosp" review="https:/
+  <remote fetch="https://aosp.tuna.tsinghua.edu.cn/" name="aosp" review="https:
   <remote fetch="https://github.com/khadas/" name="github"/>
   
   <default remote="github" revision="refs/heads/Nougat" sync-j="4"/>
gouwa@Server:~/project/khadas/aosp/.repo/manifests$ 

常见问题:

  • repo在运行过程中会尝试访问Google官方的git源更新自己,因此在运行过程中有可能出现”无法连接gerrit.googlesource.com“的问题,解决方案参考这里

  • 下载过程中如果报如下错误,检查上述VPN或者修改XML方法是否正确配置*

...
Fetching project platform/prebuilts/sdk
Fetching projects:  66% (4/6)  fatal: unable to access 'https://android.googlesource.com/platform/prebuilts/tools/': Failed to connect to android.googlesource.com port 443: Connection timed out
fatal: unable to access 'https://android.googlesource.com/platform/prebuilts/sdk/': Failed to connect to android.googlesource.com port 443: Connection timed out
fatal: unable to access 'https://android.googlesource.com/platform/prebuilts/tools/': Failed to connect to android.googlesource.com port 443: Connection timed out
fatal: unable to access 'https://android.googlesource.com/platform/prebuilts/sdk/': Failed to connect to android.googlesource.com port 443: Connection timed out
error: Cannot fetch platform/prebuilts/tools
error: Cannot fetch platform/prebuilts/sdk

error: Exited sync due to fetch errors
gouwa@Server:~/project/khadas/aosp$ 

更多参考:

1 Like