Android 国内代码下载编译
程序员文章站
2022-03-11 22:57:37
1.安装操作系统安装操作系统 Ubuntuubuntu-16.04.6-desktop-amd64.iso ubuntu-19.10-desktop-amd64.isoRedhat CentOS 和 Fedora 不是 Android 源码官方推荐。使用Ubuntu,,PC机不要使用虚拟机,太慢分硬盘分大一点500G 可以多编译几个Android2.装Android编译环境依赖包apt-get install git-core gnupg flex bison gperf buil...
1.安装操作系统
安装操作系统 Ubuntu
ubuntu-16.04.6-desktop-amd64.iso
ubuntu-19.10-desktop-amd64.iso
Redhat CentOS 和 Fedora 不是 Android 源码官方推荐,请使用Ubuntu,PC机不要使用虚拟机,太慢
分硬盘分大一点500G 可以多编译几个Android
2.装Android编译环境依赖包
apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip
3.清华园AOSP镜像站下repo
下载repo
mkdir ~/bin
PATH=~/bin:$PATH
curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o repo
cp repo ~/bin/
chmod a+x ~/bin/repo
export一下
repo的运行过程中会尝试访问官方的git源更新自己,如果想使用tuna的镜像源进行更新,可以将如下内容复制到你的~/.bashrc
里或者/etc/profile /etc/profile.d/里,怎么方便看你喜好。
export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo'
如放在.bashrc里
重启终端
4.下载代码
传统初始化方法:
//建立目录
mkdir WORKING_DIRECTORY
cd WORKING_DIRECTORY
//初始化
repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest
//初始化特定版本
repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-6.0.1_r61
//同步源码树
repo sync
遇到错误,重新多 repo sync 几把即可
remote: Total 107366 (delta 0), reused 0 (delta 0)
接收对象中: 100% (107366/107366), 5.78 GiB | 1.03 MiB/s, 完成.
处理 delta 中: 100% (73443/73443), 完成. 2.06 MiB/s
Fetching projects: 66% (8/12) platform/prebuilts/ndk接收对象中: 79% (1848/2319remote: Total 2319 (delta 0), reused 0 (delta 0)
接收对象中: 100% (2319/2319), 15.37 GiB | 3.15 MiB/s, 完成.
处理 delta 中: 100% (572/572), 完成.
Fetching projects: 75% (9/12), done.
remote: Counting objects: 79416, done.
remote: Counting objects: 62283, done.
remote: Counting objects: 111002, done. 8 MiB/s
remote: Compressing objects: 100% (46/46), done.
error: RPC failed; curl 56 GnuTLS recv error (-54): Error in the pull function.
fatal: 远端意外挂断了
fatal: 过早的文件结束符(EOF)
fatal: index-pack 失败
error: RPC failed; curl 56 GnuTLS recv error (-54): Error in the pull function.
fatal: 远端意外挂断了
fatal: 过早的文件结束符(EOF)
fatal: index-pack 失败
error: Cannot fetch platform/prebuilts/tools (UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 2578: ordinal not in range(128))
error: Cannot fetch platform/prebuilts/gradle-plugin (UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 47: ordinal not in range(128))
Exception in thread Thread-933:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
File "/mnt/opt/android6/.repo/repo/subcmds/sync.py", line 305, in _FetchProjectList
success = self._FetchHelper(opt, project, *args, **kwargs)
File "/mnt/opt/android6/.repo/repo/subcmds/sync.py", line 351, in _FetchHelper
clone_filter=clone_filter)
File "/mnt/opt/android6/.repo/repo/project.py", line 1546, in Sync_NetworkHalf
clone_filter=clone_filter, retry_fetches=retry_fetches):
File "/mnt/opt/android6/.repo/repo/project.py", line 2559, in _RemoteFetch
print('%s:\n%s' % (self.name, gitcmd.stdout), file=sys.stderr)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 2578: ordinal not in range(128)
Exception in thread Thread-934:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
File "/mnt/opt/android6/.repo/repo/subcmds/sync.py", line 305, in _FetchProjectList
success = self._FetchHelper(opt, project, *args, **kwargs)
File "/mnt/opt/android6/.repo/repo/subcmds/sync.py", line 351, in _FetchHelper
clone_filter=clone_filter)
File "/mnt/opt/android6/.repo/repo/project.py", line 1546, in Sync_NetworkHalf
clone_filter=clone_filter, retry_fetches=retry_fetches):
File "/mnt/opt/android6/.repo/repo/project.py", line 2559, in _RemoteFetch
print('%s:\n%s' % (self.name, gitcmd.stdout), file=sys.stderr)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 47: ordinal not in range(128)
remote: Total 79416 (delta 0), reused 0 (delta 0)
接收对象中: 100% (79416/79416), 4.98 GiB | 1.83 MiB/s, 完成.
处理 delta 中: 100% (26719/26719), 完成.
Fetching projects: 33% (1/3), done.
remote: Counting objects: 62283, done.
remote: Total 62283 (delta 0), reused 0 (delta 0)
接收对象中: 100% (62283/62283), 3.22 GiB | 2.42 MiB/s, 完成.
处理 delta 中: 100% (15522/15522), 完成.
remote: Counting objects: 111002, done.
remote: Compressing objects: 100% (46/46), done.
error: RPC failed; curl 56 GnuTLS recv error (-54): Error in the pull function.
fatal: 远端意外挂断了
fatal: 过早的文件结束符(EOF)
fatal: index-pack 失败
Fetching projects: 50% (1/2) platform/prebuilts/gradle-pluginerror: Cannot fetch platform/prebuilts/tools (UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 2534: ordinal not in range(128))
Exception in thread Thread-939:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
File "/mnt/opt/android6/.repo/repo/subcmds/sync.py", line 305, in _FetchProjectList
success = self._FetchHelper(opt, project, *args, **kwargs)
File "/mnt/opt/android6/.repo/repo/subcmds/sync.py", line 351, in _FetchHelper
clone_filter=clone_filter)
File "/mnt/opt/android6/.repo/repo/project.py", line 1546, in Sync_NetworkHalf
clone_filter=clone_filter, retry_fetches=retry_fetches):
File "/mnt/opt/android6/.repo/repo/project.py", line 2559, in _RemoteFetch
print('%s:\n%s' % (self.name, gitcmd.stdout), file=sys.stderr)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 2534: ordinal not in range(128)
Fetching projects: 50% (1/2), done.
remote: Counting objects: 111002, done.
remote: Compressing objects: 100% (46/46), done.
remote: Total 111002 (delta 22), reused 115 (delta 22)
接收对象中: 100% (111002/111002), 26.75 GiB | 3.78 MiB/s, 完成.
处理 delta 中: 100% (49027/49027), 完成.
Fetching projects: 100% (1/1), done.
正在检出文件: 100% (2596/2596), 完成.
Checking out projects: 1% (5/454) platform/build正在检出文件: 12% (1226/9676)正在检出文件: 100% (9676/9676), 完成.
正在检出文件: 100% (5699/5699), 完成.
Checking out projects: 2% (10/454) platform/developers/docs正在检出文件: 91% 正在检出文件: 100% (4313/4313), 完成.
正在检出文件: 100% (11736/11736), 完成.
Checking out projects: 14% (64/454) platform/external/ceres-solver正在检出文件:正在检出文件: 100% (2101/2101), 完成.
正在检出文件: 100% (10613/10613), 完成.
Checking out projects: 15% (69/454) platform/external/cmockery正在检出文件: 11正在检出文件: 100% (2067/2067), 完成.
Checking out projects: 17% (78/454) platform/external/donuts正在检出文件: 39% 正在检出文件: 100% (1317/1317), 完成.
Checking out projects: 24% (109/454) platform/external/gtest正在检出文件: 9% 正在检出文件: 100% (7397/7397), 完成.
Checking out projects: 37% (168/454) platform/external/libxml2正在检出文件: 34正在检出文件: 100% (3493/3493), 完成.
Checking out projects: 38% (173/454) platform/external/lldb正在检出文件: 5% (正在检出文件: 100% (17133/17133), 完成.
Checking out projects: 39% (178/454) platform/external/marisa-trie正在检出文件:正在检出文件: 100% (4095/4095), 完成.
Checking out projects: 46% (209/454) platform/external/ppp正在检出文件: 97% (7正在检出文件: 100% (755/755), 完成.
Checking out projects: 48% (218/454) platform/external/selinux正在检出文件: 68正在检出文件: 100% (3504/3504), 完成.
Checking out projects: 52% (237/454) platform/external/tinyxml正在检出文件: 24正在检出文件: 100% (4367/4367), 完成.
Checking out projects: 55% (250/454) platform/external/xmp_toolkit正在检出文件:正在检出文件: 100% (26633/26633), 完成.
Checking out projects: 62% (282/454) platform/frameworks/opt/telephony正在检出正在检出文件: 100% (2436/2436), 完成.
Checking out projects: 82% (373/454) platform/packages/apps/QuickSearchBox正在正在检出文件: 100% (2106/2106), 完成.
Checking out projects: 84% (382/454) platform/packages/apps/TvSettings正在检出正在检出文件: 100% (3166/3166), 完成.
Checking out projects: 86% (391/454) platform/packages/providers/ContactsProvidChecking out projects: 87% (395/454) platform/packages/providers/TelephonyProviChecking out projects: 90% (409/454) platform/packages/wallpapers/NoiseField正正在检出文件: 100% (64/64), 完成.
Checking out projects: 91% (414/454) platform/prebuilts/clang/darwin-x86/host/3正在检出文件: 100% (742/742), 完成.
正在检出文件: 100% (263/263), 完成.
Checking out projects: 92% (418/454) platform/prebuilts/gcc/darwin-x86/aarch64/正在检出文件: 100% (205/205), 完成.件: 41% (86/205)
正在检出文件: 100% (111/111), 完成.
正在检出文件: 100% (242/242), 完成.
Checking out projects: 93% (423/454) platform/prebuilts/gcc/darwin-x86/mips/mip正在检出文件: 100% (269/269), 完成.: 9% (25/269)
正在检出文件: 100% (273/273), 完成.
正在检出文件: 100% (209/209), 完成.
Checking out projects: 94% (427/454) platform/prebuilts/gcc/linux-x86/arm/arm-l正在检出文件: 100% (3202/3202), 完成.% (1413/3202)
正在检出文件: 100% (3539/3539), 完成.
正在检出文件: 100% (4198/4198), 完成.
正在检出文件: 100% (270/270), 完成.
Checking out projects: 95% (432/454) platform/prebuilts/gcc/linux-x86/x86/x86_6正在检出文件: 100% (11831/11831), 完成.2536/11831)
正在检出文件: 100% (2518/2518), 完成.
正在检出文件: 100% (1697/1697), 完成.
Checking out projects: 96% (436/454) platform/prebuilts/misc正在检出文件: 9% 正在检出文件: 100% (72214/72214), 完成.
正在检出文件: 100% (3552/3552), 完成.
正在检出文件: 100% (52/52), 完成.
正在检出文件: 100% (1368/1368), 完成.
Checking out projects: 97% (441/454) platform/prebuilts/sdk正在检出文件: 2% (正在检出文件: 100% (3838/3838), 完成.
Checking out projects: 99% (450/454) platform/system/netd正在检出文件: 44% (8/正在检出文件: 100% (18/18), 完成.
Checking out projects: 100% (454/454), done.
error: Unable to fully sync the tree.
error: Downloading network changes failed.
error: Checking out local projects failed.
Try re-running with "-j1 --fail-fast" to exit at the first error.
root@mayaoyao-Precision-Tower-5810:/mnt/opt/android6# repo sync
repo: warning: Python 2 is no longer supported; Please upgrade to Python 3.6+.
... A new version of repo (2.8) is available.
... You should upgrade soon:
cp /mnt/opt/android6/.repo/repo/repo /usr/bin/repo
remote: Counting objects: 12, done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 12 (delta 4), reused 0 (delta 0)
Fetching projects: 2% (10/454) platform/external/google-fonts/carrois-gothic-sFetching projects: 5% (23/454) device/lge/hammerhead-kernelremote: Counting objects: 13, done.
remote: Compressing objects: 100% (12/12), done.
remote: Total 13 (delta 1), reused 7 (delta 1)
Fetching projects: 6% (28/454) platform/artremote: Counting objects: 12, done.
remote: Compressing objects: 100% (12/12), done.
remote: Total 12 (delta 1), reused 9 (delta 0)
Fetching projects: 15% (69/454) platform/packages/apps/Bluetoothremote: Counting objects: 94, done.
remote: Compressing objects: 100% (94/94), done.
remote: Total 94 (delta 35), reused 0 (delta 0)
Fetching projects: 21% (96/454) platform/prebuilts/ndkremote: Counting objects: 7, done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 7 (delta 4), reused 0 (delta 0)
Fetching projects: 26% (119/454) platform/external/dhcpcdremote: Counting objects: 29, done.
remote: Compressing objects: 100% (29/29), done.
Fetching projects: 29% (132/454) platform/system/netdremote: Counting objects: 121, done.
remote: Compressing objects: 100% (113/113), done.
remote: Total 121 (delta 22), reused 23 (delta 6)
接收对象中: 100% (121/121), 443.68 KiB | 827.00 KiB/s, 完成.
处理 delta 中: 100% (22/22), 完成.
Fetching projects: 30% (137/454) platform/external/webrtcremote: Counting objects: 14, done.
remote: Compressing objects: 100% (13/13), done.
remote: Total 14 (delta 3), reused 5 (delta 0)
remote: Counting objects: 182, done.
remote: Compressing objects: 100% (108/108), done.
remote: Total 182 (delta 66), reused 121 (delta 46)
接收对象中: 100% (182/182), 155.66 KiB | 714.00 KiB/s, 完成.
处理 delta 中: 100% (66/66), 完成.
remote: Total 29 (delta 24), reused 0 (delta 0)
remote: Counting objects: 56044, done.
remote: Compressing objects: 100% (12377/12377), done.
Fetching projects: 31% (141/454) platform/frameworks/base接收对象中: 15% (8407remote: Counting objects: 16, done. 1.10 MiB/s
remote: Compressing objects: 100% (16/16), done.
remote: Total 16 (delta 11), reused 1 (delta 0)
Fetching projects: 32% (146/454) platform/hardware/intel/common/wrs_omxil_coreFetching projects: 33% (150/454) platform/prebuilts/gcc/linux-x86/x86/x86_64-liFetching projects: 34% (155/454) platform/external/google-tv-pairing-protocol接Fetching projects: 35% (159/454) platform/hardware/broadcom/libbt接收对象中: 6Fetching projects: 36% (164/454) platform/external/nanopb-c接收对象中: 75% (42Fetching projects: 37% (168/454) platform/external/netcat接收对象中: 98% (5492remote: Total 56044 (delta 44349), reused 55329 (delta 43639)
接收对象中: 100% (56044/56044), 16.61 MiB | 1.10 MiB/s, 完成.
remote: Counting objects: 16, done.
remote: Compressing objects: 100% (12/12), done.
remote: Total 16 (delta 5), reused 13 (delta 4)
Fetching projects: 38% (173/454) device/generic/x86_64处理 delta 中: 63% (2837Fetching projects: 39% (178/454) platform/external/mp4parser处理 delta 中: 84%remote: Counting objects: 8, done.
remote: Compressing objects: 100% (8/8), done.
remote: Total 8 (delta 0), reused 7 (delta 0)
处理 delta 中: 100% (44349/44349), 完成 389 个本地对象.
Fetching projects: 45% (205/454) platform/prebuilts/gcc/linux-x86/host/x86_64-wFetching projects: 48% (218/454) platform/hardware/qcom/sensorsremote: Counting objects: 15, done.
remote: Compressing objects: 100% (15/15), done.
remote: Total 15 (delta 13), reused 0 (delta 0)
Fetching projects: 49% (223/454) platform/packages/providers/UserDictionaryProviderremote: Counting objects: 10, done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 10 (delta 7), reused 0 (delta 0)
Fetching projects: 57% (259/454) platform/system/mediaremote: Counting objects: 18, done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 18 (delta 6), reused 0 (delta 0)
Fetching projects: 59% (268/454) platform/hardware/broadcom/wlanremote: Counting objects: 57, done.
remote: Compressing objects: 100% (57/57), done.
remote: Total 57 (delta 38), reused 0 (delta 0)
Fetching projects: 62% (282/454) platform/external/apache-harmonyremote: Counting objects: 7, done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 7 (delta 2), reused 5 (delta 2)
Fetching projects: 64% (291/454) platform/external/libpcapremote: Counting objects: 4, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 4 (delta 2), reused 0 (delta 0)
Fetching projects: 67% (305/454) platform/external/oauthremote: Counting objects: 1216, done.
remote: Compressing objects: 100% (689/689), done.
remote: Total 1216 (delta 229), reused 1024 (delta 170)
接收对象中: 100% (1216/1216), 713.19 KiB | 1.16 MiB/s, 完成.
处理 delta 中: 100% (229/229), 完成.
Fetching projects: 72% (327/454) platform/frameworks/opt/widgetremote: Counting objects: 57, done.
remote: Compressing objects: 100% (57/57), done.
remote: Total 57 (delta 44), reused 0 (delta 0)
Fetching projects: 77% (350/454) platform/bionicremote: Counting objects: 586, done.
remote: Compressing objects: 100% (272/272), done.
Fetching projects: 78% (355/454) platform/packages/apps/CarrierConfigremote: Counting objects: 598, done.
remote: Compressing objects: 100% (269/269), done.
remote: Total 598 (delta 496), reused 430 (delta 329)
接收对象中: 100% (598/598), 97.74 KiB | 1.21 MiB/s, 完成.
处理 delta 中: 100% (496/496), 完成 105 个本地对象./s
Fetching projects: 79% (359/454) platform/prebuilts/gcc/linux-x86/arm/arm-eabi-remote: Total 586 (delta 360), reused 410 (delta 310)
接收对象中: 100% (586/586), 1.34 MiB | 743.00 KiB/s, 完成.
处理 delta 中: 100% (360/360), 完成.
Fetching projects: 81% (368/454) platform/developers/samples/androidremote: Counting objects: 4, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 4 (delta 3), reused 0 (delta 0)
Fetching projects: 88% (400/454) platform/packages/apps/CellBroadcastReceiverremote: Counting objects: 12, done.
remote: Compressing objects: 100% (12/12), done.
remote: Total 12 (delta 10), reused 0 (delta 0)
Fetching projects: 89% (405/454) platform/packages/apps/CertInstallerremote: Counting objects: 437, done.
remote: Compressing objects: 100% (404/404), done.
remote: Total 437 (delta 23), reused 418 (delta 15)
接收对象中: 100% (437/437), 150.28 KiB | 57.00 KiB/s, 完成.
处理 delta 中: 100% (23/23), 完成.
Fetching projects: 96% (436/454) platform/external/pcreremote: Counting objects: 43, done.
remote: Compressing objects: 100% (38/38), done.
remote: Total 43 (delta 17), reused 5 (delta 0)
Fetching projects: 98% (445/454) device/sampleremote: Counting objects: 10, done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 10 (delta 1), reused 0 (delta 0)
Fetching projects: 100% (454/454), done.
Checking out projects: 86% (391/454) platform/packages/providers/ContactsProvidChecking out projects: 87% (395/454) platform/packages/providers/TelephonyProviChecking out projects: 91% (414/454) platform/prebuilts/clang/darwin-x86/host/3Checking out projects: 92% (418/454) platform/prebuilts/gcc/darwin-x86/aarch64/Checking out projects: 93% (423/454) platform/prebuilts/gcc/darwin-x86/mips/mipChecking out projects: 94% (427/454) platform/prebuilts/gcc/linux-x86/arm/arm-lChecking out projects: 95% (432/454) platform/prebuilts/gcc/linux-x86/x86/x86_6Checking out projects: 100% (454/454), done.
repo sync has finished successfully.
root@mayaoyao-Precision-Tower-5810:/mnt/opt/android6# repo sync
repo: warning: Python 2 is no longer supported; Please upgrade to Python 3.6+.
... A new version of repo (2.8) is available.
... You should upgrade soon:
cp /mnt/opt/android6/.repo/repo/repo /usr/bin/repo
Fetching projects: 37% (168/454) platform/packages/providers/PartnerBookmarksPrFetching projects: 45% (205/454) platform/prebuilts/gcc/linux-x86/host/x86_64-wFetching projects: 100% (454/454) platform/prebuilts/gcc/darwin-x86/host/i686-apFetching projects: 100% (454/454), done.
Checking out projects: 86% (391/454) platform/packages/providers/ContactsProvidChecking out projects: 87% (395/454) platform/packages/providers/TelephonyProviChecking out projects: 91% (414/454) platform/prebuilts/clang/darwin-x86/host/3Checking out projects: 92% (418/454) platform/prebuilts/gcc/darwin-x86/aarch64/Checking out projects: 93% (423/454) platform/prebuilts/gcc/darwin-x86/mips/mipChecking out projects: 94% (427/454) platform/prebuilts/gcc/linux-x86/arm/arm-lChecking out projects: 95% (432/454) platform/prebuilts/gcc/linux-x86/x86/x86_6Checking out projects: 100% (454/454), done.
repo sync has finished successfully.
root@mayaoyao-Precision-Tower-5810:/mnt/opt/android6#
Android 源码大约120 -150G 耐心等待即可
root@mayaoyao-Precision-Tower-5810:/mnt/opt# du -sh *
121G android6
1.6G ubuntu-16.04.6-desktop-amd64.iso
2.3G ubuntu-19.10-desktop-amd64.iso
root@mayaoyao-Precision-Tower-5810:/mnt/opt#
下载以后的Android源码编译之前备份一把,以免编坏了重新撸代码
root@mayaoyao-Precision-Tower-5810:/mnt/opt# du -sh *
121G android6
1.6G ubuntu-16.04.6-desktop-amd64.iso
2.3G ubuntu-19.10-desktop-amd64.iso
root@mayaoyao-Precision-Tower-5810:/mnt/opt#
安装OpenJDK
apt-get install openjdk-13-jdk
5.编译
本文地址:https://blog.csdn.net/weixin_41557838/article/details/108128018
下一篇: Dimen 自动生成