android aosp源码下载及编译实践

家电修理 2023-07-16 19:16www.caominkang.com电器维修

下载源码各种坑,特此记录一下

root@lxb-virtual-machine:~/bin# cd ~/bin/aosp
root@lxb-virtual-machine:~/bin/aosp# repo init -u git://mirrors.ustc.edu./aosp/platform/manifest -b android-10.0.0_r17

报错日志1:

repo: reusing existing repo client checkout in /root/bin/aosp
Traceback (most recent call last):
  File "/root/bin/aosp/.repo/repo/main.py", line 705, in
    _Main(sys.argv[1:])
  File "/root/bin/aosp/.repo/repo/main.py", line 681, in _Main
    result = repo._Run(name, gopts, argv) or 0
  File "/root/bin/aosp/.repo/repo/main.py", line 228, in _Run
    result = run()
  File "/root/bin/aosp/.repo/repo/main.py", line 219, in
    run = lambda: self._RunLong(name, gopts, argv) or 0
  File "/root/bin/aosp/.repo/repo/main.py", line 314, in _RunLong
    result = cmd.Execute(copts, cargs)
  File "/root/bin/aosp/.repo/repo/subcmds/init.py", line 325, in Execute
    self._SyncManifest(opt)
  File "/root/bin/aosp/.repo/repo/subcmds/init.py", line 116, in _SyncManifest
    if not self.manifest.manifestProject.Sync(
  File "/root/bin/aosp/.repo/repo/project.py", line 3863, in Sync
    self.MetaBranchSitch(submodules=submodules)
  File "/root/bin/aosp/.repo/repo/project.py", line 3427, in MetaBranchSitch
    self.Sync_LocalHalf(syncbuf, submodules=submodules)
  File "/root/bin/aosp/.repo/repo/project.py", line 1380, in Sync_LocalHalf
    lost = self._revlist(not_rev(revid), HEAD)
  File "/root/bin/aosp/.repo/repo/project.py", line 2959, in _revlist
    return self.ork_git.rev_list(a, k)
  File "/root/bin/aosp/.repo/repo/project.py", line 3172, in rev_list
    raise GitError('%s rev-list %s: %s' %
error.GitError: manifests rev-list ('^4531c2f30a224a7782a4dd245f5d90ce84e2941d', 'HEAD', '--'): fatal: detected dubious onership in repository at '/root/bin/aosp/.repo/manifests'
To add an exception for this directory, call:

    git config --global --add safe.directory /root/bin/aosp/.repo/manifests


解决方案
https://blog.csdn./u010164190/article/details/125089071

root@lxb-virtual-machine:~/bin/aosp# repo sync -c

报错日志2
remote: Enumerating objects: 2, done.
remote: Counting objects: 100% (2/2), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 1
Traceback (most recent call last):
  File "/root/bin/aosp/.repo/repo/main.py", line 705, in
    _Main(sys.argv[1:])
  File "/root/bin/aosp/.repo/repo/main.py", line 681, in _Main
    result = repo._Run(name, gopts, argv) or 0
  File "/root/bin/aosp/.repo/repo/main.py", line 228, in _Run
    result = run()
  File "/root/bin/aosp/.repo/repo/main.py", line 219, in
    run = lambda: self._RunLong(name, gopts, argv) or 0
  File "/root/bin/aosp/.repo/repo/main.py", line 314, in _RunLong
    result = cmd.Execute(copts, cargs)
  File "/root/bin/aosp/.repo/repo/subcmds/sync.py", line 1276, in Execute
    self._UpdateAllManifestProjects(opt, mp, manifest_name)
  File "/root/bin/aosp/.repo/repo/subcmds/sync.py", line 1156, in _UpdateAllManifestProjects
    self._UpdateManifestProject(opt, mp, manifest_name)
  File "/root/bin/aosp/.repo/repo/subcmds/sync.py", line 1193, in _UpdateManifestProject
    if mp.HasChanges:
  File "/root/bin/aosp/.repo/repo/project.py", line 3402, in HasChanges
    elif self._revlist(not_rev(HEAD), revid):
  File "/root/bin/aosp/.repo/repo/project.py", line 2959, in _revlist
    return self.ork_git.rev_list(a, k)
  File "/root/bin/aosp/.repo/repo/project.py", line 3172, in rev_list
    raise GitError('%s rev-list %s: %s' %
error.GitError: manifests rev-list ('^HEAD', '18d194c624a0260dec68ffa6a3b021351379c7b4', '--'): fatal: detected dubious onership in repository at '/root/bin/aosp/.repo/manifests'
To add an exception for this directory, call:

    git config --global --add safe.directory /root/bin/aosp/.repo/manifests
解决方案
按照提示,先执行如下,再初始化仓库
git config --global --add safe.directory /root/bin/aosp/.repo/manifests
初始化仓库
repo init -u git://mirrors.ustc.edu./aosp/platform/manifest -b android-10.0.0_r17

报错日志3
root@lxb-virtual-machine:~/bin/aosp/.repo/manifests# git config --global --add safe.directory /root/bin/aosp/.repo/manifests
root@lxb-virtual-machine:~/bin/aosp/.repo/manifests# repo init -u git://mirrors.ustc.edu./aosp/platform/manifest -b android-10.0.0_r17
repo: reusing existing repo client checkout in /root/bin/aosp
.repo/manifests/: discarding 554 mits

Testing colorized output (for 'repo diff', 'repo status'):
  black    red      green    yello   blue     magenta   cyan     hite 
  bold     dim      ul       reverse 
Enable color display in this user aount (y/N)? 
报错日志4

root@lxb-virtual-machine:~/bin/aosp/.repo/manifests# repo init -u git://mirrors.ustc.edu./aosp/platform/manifest -b android-10.0.0_r17
repo: reusing existing repo client checkout in /root/bin/aosp

repo has been initialized in /root/bin/aosp
If this is not the directory in hich you ant to initialize repo, please run:
   rm -r /root/bin/aosp/.repo
and try again.
root@lxb-virtual-machine:~/bin/aosp/.repo/manifests# 

解决方案输入y 后,显示repo has been initialized in /root/bin/aosp  代表初始化仓库成功
参考链接https://segmentfault./a/1190000041030634


repo sync
同步repo成功

正在更新文件: 100% (261/261), 完成.
正在更新文件: 100% (1765/1765), 完成.
正在更新文件: 100% (1898/1898), 完成.frameorks/opt/car/setupizard正在更新文件: 100% (1898/1898)
正在更新文件: 100% (146/146), 完成.m/frameorks/opt//ims正在更新文件:   8% (774/9153)
正在更新文件: 100% (9153/9153), 完成.
正在更新文件: 100% (1442/1442), 完成.
正在更新文件: 100% (9151/9151), 完成.
正在更新文件: 100% (2018/2018), 完成.
正在更新文件: 100% (972/972), 完成.
正在更新文件: 100% (34105/34105), 完成.stem/libfmq正在更新文件:  29% (10178/34105)
正在更新文件: 100% (683/683), 完成.
正在更新文件: 100% (763/763), 完成.
Checking out: 100% (733/733), done in 24m10.940s
repo sync has finished suessfully.
root@lxb-virtual-machine:~/bin/aosp/.repo/manifests# 


报错日志5
root@lxb-virtual-machine:~/bin/aosp/.repo/manifests#  udo apt-get install git-core gnupg flex bison build-essential zip curl zlib1g-dev g-multilib g++-multilib libc6-dev-i386 libncurses5 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev libxml2-utils xsltproc unzip fontconfig libncurses5
                                                                                            sudo apt-get install git-core gnupg flex bison build-essential zip curl zlib1g-dev g-multilib g++-multilib libc6-dev-i386 libncurses5 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev libxml2-utils xsltproc unzip fontconfig
Error:  0: couldn't open source file
libncurses5.ui: No such file or directory

解决方案编译环境命令敲错了 sudo  不是 udo

报错日志6:
root@lxb-virtual-machine:~/bin/aosp/.repo/manifests# sudo add-apt-repository ppa:openjdk-r/ppa
 
 更多信息 https://launchpad./~openjdk-r/+archive/ubuntu/ppa
按 [ENTER] 继续或 Ctrl-c 取消安装。

Error: retrieving gpg key timed out.

解决方案从新执行命令,成功
如果成功还是超时,可参考  https://.jianshu./p/e2a15336f174


root@lxb-virtual-machine:~/bin/aosp/.repo/manifests# cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.5 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.5 LTS"
VERSION_ID="20.04"
HOME_URL="https://.ubuntu./"
SUPPORT_URL="https://help.ubuntu./"
BUG_REPORT_URL="https://bugs.launchpad./ubuntu/"
PRIVACY_POLICY_URL="https://.ubuntu./legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
root@lxb-virtual-machine:~/bin/aosp/.repo/manifests# 


报错日志7

root@lxb-virtual-machine:~/bin/aosp# . build/envsetup.sh
root@lxb-virtual-machine:~/bin/aosp# lunch sdk_phone_x86_64

[W][2022-12-07T16:35:51+0800][51218] void cmdline::logParams(nsjconf_t )():250 Process ill be UID/EUID=0 in the global user namespace, and ill have user root-level aess to files
[W][2022-12-07T16:35:51+0800][51218] void cmdline::logParams(nsjconf_t )():260 Process ill be GID/EGID=0 in the global user namespace, and ill have group root-level aess to files

============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=10
TARGET_PRODUCT=sdk_phone_x86_64
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_ARCH=x86_64
TARGET_ARCH_VARIANT=x86_64
TARGET_2ND_ARCH=x86
TARGET_2ND_ARCH_VARIANT=x86_64
HOST_ARCH=x86_64
HOST_2ND_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-5.15.0-56-generic-x86_64-Ubuntu-20.04.5-LTS
HOST_CROSS_OS=indos
HOST_CROSS_ARCH=x86
HOST_CROSS_2ND_ARCH=x86_64
HOST_BUILD_TYPE=release
BUILD_ID=QP1A.191005.007.A3
OUT_DIR=out
============================================

解决方案https://blog.csdn./nei504293736/article/details/109628378

报错日志8
注: 某些输入文件使用或覆盖了已过时的 API。
注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。
注: 某些输入文件使用了未经检查或不安全的操作。
注: 有关详细信息, 请使用 -Xlint:unchecked 重新编译。
[ 98% 109680/111768] //system/bt/proto:bluetooth-protos-lite javac [mon]
注: out/soong/.intermediates/system/bt/proto/bluetooth-protos-lite/android_mon/javac/srcjars//android/bluetooth/BluetoothMetricsProto.java使用了未经检查或不安全的操作。
注: 有关详细信息, 请使用 -Xlint:unchecked 重新编译。
[ 98% 109687/111768] //frameorks/base/cmds/bmgr:bmgr javac [mon]
注: frameorks/base/cmds/bmgr/src//android/mands/bmgr/Bmgr.java使用或覆盖了已过时的 API。
注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。
注: frameorks/base/cmds/bmgr/src//android/mands/bmgr/Bmgr.java使用了未经检查或不安全的操作。
注: 有关详细信息, 请使用 -Xlint:unchecked 重新编译。
[ 98% 109689/111768] //frameorks/base/libs/usb:.android.future.usb.aessory javac [mon]
注: frameorks/base/libs/usb/src//android/future/usb/UsbManager.java使用或覆盖了已过时的 API。
注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。
[ 98% 109713/111768] //frameorks/base/packages/FusedLocation:FusedLocation javac [mon]
注: 某些输入文件使用或覆盖了已过时的 API。
注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。
FAILED: [W][2022-12-07T17:24:12+0800][54978] void cmdline::logParams(nsjconf_t )():250 Process ill be UID/EUID=0 in the global user namespace, and ill have user root-level aess to files
[W][2022-12-07T17:24:12+0800][54978] void cmdline::logParams(nsjconf_t )():260 Process ill be GID/EGID=0 in the global user namespace, and ill have group root-level aess to files

22:18:41 ninja failed ith: exit status 137

#### failed to build some targets (05:40:31 (hh:mm:ss)) ####

解决方案内存分配导致,JavacHeapSize
https://juejin./post/7158741169001168927


报错日志9
bin/soong_zip -rite_if_changed -jar -o out/soong/.intermediates/frameorks/base/system-api-stubs-docs/android_mon/system-api-stubs-docs-stubs.srcjar -C out/soong/.intermediates/frameorks/base/system-api-stubs-docs/android_mon/stubsDir -D out/soong/.intermediates/frameorks/base/system-api-stubs-docs/android_mon/stubsDir && rm -rf "out/soong/.intermediates/frameorks/base/system-api-stubs-docs/android_mon/srcjars"
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
    at java.base/java.lang.StringLatin1.toChars(StringLatin1.java:70)
    at java.base/java.lang.String.toCharArray(String.java:2705)
    at .android.tools.metalava.doclava1.ApiFile.parseApi(ApiFile.java:95)
    at .android.tools.metalava.doclava1.ApiFile.parseApi(ApiFile.java:69)
    at .android.tools.metalava.SignatureFileLoader.loadFromSignatureFiles(SignatureFileLoader.kt:42)
    at .android.tools.metalava.SignatureFileLoader.load(SignatureFileLoader.kt:31)
    at .android.tools.metalava.Driver.processFlags(Driver.kt:384)
    at .android.tools.metalava.Driver.run(Driver.kt:147)
    at .android.tools.metalava.Driver.run$default(Driver.kt:98)
    at .android.tools.metalava.Driver.main(Driver.kt:86)
FAILED: [W][2022-12-08T11:59:44+0800][545296] void cmdline::logParams(nsjconf_t )():250 Process ill be UID/EUID=0 in the global user namespace, and ill have user root-level aess to files
[W][2022-12-08T11:59:44+0800][545296] void cmdline::logParams(nsjconf_t )():260 Process ill be GID/EGID=0 in the global user namespace, and ill have group root-level aess to files
19:07:24 ninja failed ith: exit status 1

#### failed to build some targets (07:24:10 (hh:mm:ss)) ####
解决方案:

报错日志10
ndroid.okhttp --hide-package .android..conscrypt --hide-package .android.server --error UnhiddenSystemApi --hide RequiresPermission --hide MissingPermission --hide BroadcastBehavior --hide HiddenSuperclass --hide DeprecationMismatch --hide UnavailableSymbol --hide SdkConstant --hide HiddenTypeParameter --hide Todo --hide Typo --sho-annotation android.annotation.SystemApi && out/soong/host/linux-x86/bin/soong_zip -rite_if_changed -jar -o out/soong/.intermediates/frameorks/base/system-api-stubs-docs/android_mon/system-api-stubs-docs-stubs.srcjar -C out/soong/.intermediates/frameorks/base/system-api-stubs-docs/android_mon/stubsDir -D out/soong/.intermediates/frameorks/base/system-api-stubs-docs/android_mon/stubsDir && rm -rf "out/soong/.intermediates/frameorks/base/system-api-stubs-docs/android_mon/srcjars"
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
    at java.base/java.util.Arrays.copyOfRange(Arrays.java:4029)
    at java.base/java.lang.StringLatin1.neString(StringLatin1.java:549)
    at java.base/java.lang.StringBuilder.toString(StringBuilder.java:415)
    at .android.tools.lint.checks.infrastructure.ClassNameKt.stripComments(ClassName.kt:125)
    at .android.tools.metalava.doclava1.ApiFile.parseApi(ApiFile.java:92)
    at .android.tools.metalava.doclava1.ApiFile.parseApi(ApiFile.java:69)
    at .android.tools.metalava.SignatureFileLoader.loadFromSignatureFiles(SignatureFileLoader.kt:42)
    at .android.tools.metalava.SignatureFileLoader.load(SignatureFileLoader.kt:31)
    at .android.tools.metalava.Driver.processFlags(Driver.kt:384)
    at .android.tools.metalava.Driver.run(Driver.kt:147)
    at .android.tools.metalava.Driver.run$default(Driver.kt:98)
    at .android.tools.metalava.Driver.main(Driver.kt:86)
FAILED: [W][2022-12-09T11:34:18+0800][1043346] void cmdline::logParams(nsjconf_t )():250 Process ill be UID/EUID=0 in the global user namespace, and ill have user root-level aess to files
[W][2022-12-09T11:34:18+0800][1043346] void cmdline::logParams(nsjconf_t )():260 Process ill be GID/EGID=0 in the global user namespace, and ill have group root-level aess to files
18:31:54 ninja failed ith: exit status 1

#### failed to build some targets (07:07:12 (hh:mm:ss)) ####

root@lxb-virtual-machine:~/bin/aosp# 

~无语,虽然还是下载失败了,这个过程还是要趟一下.

1.环境搭建

VMare安装虚拟机操作步骤
https://blog.csdn./eixin_48375618/article/details/125724469
VMare安装Ubuntu详细步骤
https://blog.csdn./m0_53682138/article/details/121686154

Ubuntu镜像官方下载网站下载Ubuntu桌面系统 | Ubuntu
https://.ubuntu./donload/desk

Windos10中操作VMare 及其ubuntu虚拟机的卸载与重装
http://.corina./article/131/

建议采用这种方式(ubuntu翻墙下载源码)
ubuntu翻墙 clash安装
安装参考二
https://.blogs./mozhen/p/16306061.html
https://.blogs./zhuangjie/p/15780674.html
安装参考一
https://.icode9./content-3-1040233.html

2.下载源码

自己下载源码编译安卓系统实践  (推荐这个,这个坑少一些)
https://.pudn./nes/625e2a24131e9f3c1e06df8e.html
下载版本对应驱动(单纯编译源码可以先不用下载驱动,真机上需要下载对应驱动)
https://.blogs./roothide/p/16553963.html

编译源码
https://.pudn./nes/62a84383194b3b0e435e9598.html

ubuntu扩大sap方法
https://zhuanlan.zhihu./p/480903179

Copyright © 2016-2025 www.caominkang.com 曹敏电脑维修网 版权所有 Power by