我们专注攀枝花网站设计 攀枝花网站制作 攀枝花网站建设
成都网站建设公司服务热线:400-028-6601

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

androidaosp源码下载及编译实践-创新互联

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

成都创新互联公司致力于互联网品牌建设与网络营销,包括网站设计制作、成都网站制作、SEO优化、网络推广、整站优化营销策划推广、电子商务、移动互联网营销等。成都创新互联公司为不同类型的客户提供良好的互联网应用定制及解决方案,成都创新互联公司核心团队10年专注互联网开发,积累了丰富的网站经验,为广大企业客户提供一站式企业网站建设服务,在网站建设行业内树立了良好口碑。

root@lxb-virtual-machine:~/bin# cd ~/bin/aosp
root@lxb-virtual-machine:~/bin/aosp# repo init -u git://mirrors.ustc.edu.cn/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.MetaBranchSwitch(submodules=submodules)
File "/root/bin/aosp/.repo/repo/project.py", line 3427, in MetaBranchSwitch
  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.work_git.rev_list(*a, **kw)
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 ownership 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.net/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.work_git.rev_list(*a, **kw)
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 ownership 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.cn/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.cn/aosp/platform/manifest -b android-10.0.0_r17
repo: reusing existing repo client checkout in /root/bin/aosp
.repo/manifests/: discarding 554 commits

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

root@lxb-virtual-machine:~/bin/aosp/.repo/manifests# repo init -u git://mirrors.ustc.edu.cn/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 which you want 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.com/a/1190000041030634

repo sync
同步repo成功

正在更新文件: 100% (261/261), 完成.
正在更新文件: 100% (1765/1765), 完成.
正在更新文件: 100% (1898/1898), 完成.frameworks/opt/car/setupwizard正在更新文件: 100% (1898/1898)
正在更新文件: 100% (146/146), 完成.m/frameworks/opt/net/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 successfully.
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 gcc-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 gcc-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.net/~openjdk-r/+archive/ubuntu/ppa
按 [ENTER] 继续或 Ctrl-c 取消安装。

Error: retrieving gpg key timed out.

解决方案:从新执行命令,成功
如果成功还是超时,可参考  https://www.jianshu.com/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://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/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 will be UID/EUID=0 in the global user namespace, and will have user root-level access to files
[W][2022-12-07T16:35:51+0800][51218] void cmdline::logParams(nsjconf_t *)():260 Process will be GID/EGID=0 in the global user namespace, and will have group root-level access 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=windows
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.net/nei504293736/article/details/109628378

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

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

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

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

报错日志9:
bin/soong_zip -write_if_changed -jar -o out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/system-api-stubs-docs-stubs.srcjar -C out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/stubsDir -D out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/stubsDir && rm -rf "out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/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 com.android.tools.metalava.doclava1.ApiFile.parseApi(ApiFile.java:95)
 at com.android.tools.metalava.doclava1.ApiFile.parseApi(ApiFile.java:69)
 at com.android.tools.metalava.SignatureFileLoader.loadFromSignatureFiles(SignatureFileLoader.kt:42)
 at com.android.tools.metalava.SignatureFileLoader.load(SignatureFileLoader.kt:31)
 at com.android.tools.metalava.Driver.processFlags(Driver.kt:384)
 at com.android.tools.metalava.Driver.run(Driver.kt:147)
 at com.android.tools.metalava.Driver.run$default(Driver.kt:98)
 at com.android.tools.metalava.Driver.main(Driver.kt:86)
FAILED: [W][2022-12-08T11:59:44+0800][545296] void cmdline::logParams(nsjconf_t *)():250 Process will be UID/EUID=0 in the global user namespace, and will have user root-level access to files
[W][2022-12-08T11:59:44+0800][545296] void cmdline::logParams(nsjconf_t *)():260 Process will be GID/EGID=0 in the global user namespace, and will have group root-level access to files
19:07:24 ninja failed with: exit status 1

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

报错日志10:
ndroid.okhttp --hide-package com.android.org.conscrypt --hide-package com.android.server --error UnhiddenSystemApi --hide RequiresPermission --hide MissingPermission --hide BroadcastBehavior --hide HiddenSuperclass --hide DeprecationMismatch --hide UnavailableSymbol --hide SdkConstant --hide HiddenTypeParameter --hide Todo --hide Typo --show-annotation android.annotation.SystemApi && out/soong/host/linux-x86/bin/soong_zip -write_if_changed -jar -o out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/system-api-stubs-docs-stubs.srcjar -C out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/stubsDir -D out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/stubsDir && rm -rf "out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/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.newString(StringLatin1.java:549)
 at java.base/java.lang.StringBuilder.toString(StringBuilder.java:415)
 at com.android.tools.lint.checks.infrastructure.ClassNameKt.stripComments(ClassName.kt:125)
 at com.android.tools.metalava.doclava1.ApiFile.parseApi(ApiFile.java:92)
 at com.android.tools.metalava.doclava1.ApiFile.parseApi(ApiFile.java:69)
 at com.android.tools.metalava.SignatureFileLoader.loadFromSignatureFiles(SignatureFileLoader.kt:42)
 at com.android.tools.metalava.SignatureFileLoader.load(SignatureFileLoader.kt:31)
 at com.android.tools.metalava.Driver.processFlags(Driver.kt:384)
 at com.android.tools.metalava.Driver.run(Driver.kt:147)
 at com.android.tools.metalava.Driver.run$default(Driver.kt:98)
 at com.android.tools.metalava.Driver.main(Driver.kt:86)
FAILED: [W][2022-12-09T11:34:18+0800][1043346] void cmdline::logParams(nsjconf_t *)():250 Process will be UID/EUID=0 in the global user namespace, and will have user root-level access to files
[W][2022-12-09T11:34:18+0800][1043346] void cmdline::logParams(nsjconf_t *)():260 Process will be GID/EGID=0 in the global user namespace, and will have group root-level access to files
18:31:54 ninja failed with: exit status 1

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

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

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

1.环境搭建

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

Ubuntu镜像官方下载网站:下载Ubuntu桌面系统 | Ubuntu
https://cn.ubuntu.com/download/desktop

Windows10中操作VMware 及其ubuntu虚拟机的卸载与重装
http://www.corina.cc/article/131/

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

2.下载源码

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

编译源码
https://www.pudn.com/news/62a84383194b3b0e435e9598.html

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

你是否还在寻找稳定的海外服务器提供商?创新互联www.cdcxhl.cn海外机房具备T级流量清洗系统配攻击溯源,准确流量调度确保服务器高可用性,企业级服务器适合批量采购,新人活动首月15元起,快前往官网查看详情吧


新闻名称:androidaosp源码下载及编译实践-创新互联
本文地址:http://mswzjz.cn/article/djesoj.html

其他资讯