最近准备更新专栏文章,AOSP源码自然也需要进行更新了,但这次不是为最新的android 13, 而是取android 12的最新tag version: android-12.1.0_r27,这应该是市面上的主流版本。
第1篇:Repo下载AOSP源码:基于ubuntu22.04 环境配置
第2篇:Repo下载、编译AOSP源码:基于Ubuntu 21.04,android-12.1.0_r27
请参考第1篇文章的第2节和第3节,完成repo、 python3.9的配置
谷歌官方依赖
sudo apt-get install git-core gnupg flex bison build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 libncurses5-dev lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev libxml2-utils xsltproc unzip fontconfig
补充依赖
sudo apt install libncurses5
wget -c https://mirrors.tuna.tsinghua.edu.cn/aosp-monthly/aosp-latest.tar # 下载初始化包
tar xf aosp-latest.tar
- 示例
```bash
szhou@bc04:~/aosp/aosp$ repo sync -j4
szhou@bc03:~/works/aosp/aosp$cd .repo/manifests
szhou@bc03:~/works/aosp/aosp/.repo/manifests$ git branch -a
szhou@bc04:~/aosp/aosp/.repo/manifests.git$ git branch -a | grep "android-12.1"
remotes/m/android-12.1.0_r27 -> origin/android-12.1.0_r27
remotes/origin/android-12.1.0_r1
remotes/origin/android-12.1.0_r10
remotes/origin/android-12.1.0_r11
remotes/origin/android-12.1.0_r12
remotes/origin/android-12.1.0_r13
remotes/origin/android-12.1.0_r14
remotes/origin/android-12.1.0_r15
remotes/origin/android-12.1.0_r16
remotes/origin/android-12.1.0_r17
remotes/origin/android-12.1.0_r18
remotes/origin/android-12.1.0_r19
remotes/origin/android-12.1.0_r2
remotes/origin/android-12.1.0_r20
remotes/origin/android-12.1.0_r21
remotes/origin/android-12.1.0_r22
remotes/origin/android-12.1.0_r23
remotes/origin/android-12.1.0_r24
remotes/origin/android-12.1.0_r25
remotes/origin/android-12.1.0_r26
remotes/origin/android-12.1.0_r27
remotes/origin/android-12.1.0_r3
remotes/origin/android-12.1.0_r4
remotes/origin/android-12.1.0_r5
remotes/origin/android-12.1.0_r6
remotes/origin/android-12.1.0_r7
remotes/origin/android-12.1.0_r8
remotes/origin/android-12.1.0_r9
szhou@bc04:~/aosp/aosp/.repo/manifests.git$
可见 android-12.1.0_r27 为最新版本,我们就下载这一个版本
szhou@bc04:~/aosp/aosp$ repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-12.1.0_r27
.repo/manifests/: discarding 491 commits
Your identity is: szhou<66176468@qq.com>
If you want to change this, please re-run 'repo init' with --config-name
repo has been initialized in /home/szhou/aosp/aosp
szhou@bc04:~/aosp/aosp$ repo sync -j4
目前遇到的repo同步错误,通过删除错误的project子目录之后,基本都可以完成同步,尚未遇到过异常。也可详细参考第1篇文章的介绍
处理 delta 中: 87% (249971/286655), 完成 1 个本地对象.
fatal: 包有 36684 个未解决的 delta
fatal: fetch-pack: invalid index-pack output
error: Cannot fetch platform/packages/apps/Settings from https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/packages/apps/Settings
Fetching: 100% (1/1), done in 2m18.049s
Checking out: 45% (474/1040) platform/external/rust/crates/lru-cacheerror.GitError: Cannot checkout platform/packages/apps/Settings: platform/packages/apps/Settings rev-list ('^1a2ab44a46f248a3ba5b1875efeee652c2a20747', 'HEAD', '--'): fatal: bad object 1a2ab44a46f248a3ba5b1875efeee652c2a20747
error: Cannot checkout platform/packages/apps/Settings
Checking out: 100% (1040/1040), done in 1m22.491s
error: Unable to fully sync the tree.
error: Downloading network changes failed.
error: Checking out local projects failed.
Failing repos:
packages/apps/Settings
Try re-running with "-j1 --fail-fast" to exit at the first error.
解决办法如下所示, 将失败的子项目,做 rm -rf 处理,记得同一个错误,要删除2个部分
szhou@bc04:~/aosp/aosp$ rm -rf packages/apps/Settings
szhou@bc04:~/aosp/aosp$ rm -rf .repo/projects/packages/apps/Settings.git/
szhou@bc04:~/aosp/aosp$ repo sync
prebuilts/vndk/v28/: discarding 1 commits
prebuilts/vndk/v29/: discarding 1 commits
prebuilts/vndk/v30/: discarding 1 commits
正在更新文件: 100% (18247/18247), 完成.
sdk/: discarding 3 commits
system/apex/: discarding 238 commits
system/bpf/: discarding 51 commits
system/bpfprogs/: discarding 13 commits
system/bt/: discarding 415 commits
Checking out: 100% (1052/1052), done in 3m52.541s
repo sync has finished successfully.
szhou@bc04:~/aosp/aosp$
szhou@bc04:~/aosp/aosp$ source build/envsetup.sh
szhou@bc04:~/aosp/aosp$ lunch aosp_x86_64-eng
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=12
TARGET_PRODUCT=aosp_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.11.0-49-generic-x86_64-Ubuntu-21.04
HOST_CROSS_OS=windows
HOST_CROSS_ARCH=x86
HOST_CROSS_2ND_ARCH=x86_64
HOST_BUILD_TYPE=release
BUILD_ID=SP2A.220505.008
OUT_DIR=out
PRODUCT_SOONG_NAMESPACES=device/generic/goldfish device/generic/goldfish-opengl hardware/google/camera hardware/google/camera/devices/EmulatedCamera
============================================
szhou@bc04:~/aosp/aosp$ make -j64
对于AOSP的官方源码的编译,出现错误大致有3种情况:
大部分错误,就是代码未对齐、工具缺失依赖的错误
[100% 1/1] out/soong/.bootstrap/bin/soong_build out/soong/build.ninja
FAILED: out/soong/build.ninja
cd "$(dirname "out/soong/.bootstrap/bin/soong_build")" && BUILDER="$PWD/$(basename "out/soong/.bootstrap/bin/soong_build")" && cd / && env -i "$BUILDER" --top "$TOP" --out "out/soong" -n "out" -d "out/soong/build.ninja.d" -t -l out/.module_paths/Android.bp.list -globFile out/soong/.bootstrap/build-globs.ninja -o out/soong/build.ninja --available_env out/soong/soong.environment.available --used_env out/soong/soong.environment.used Android.bp
error: frameworks/base/Android.bp:163:1: "framework-all" depends on undefined module "framework-permission.impl"
error: frameworks/base/Android.bp:163:1: "framework-all" depends on undefined module "framework-permission-s.impl"
13:58:17 soong bootstrap failed with: exit status 1
#### failed to build some targets (21 seconds) ####
szhou@bc04:~/aosp/aosp$
sudo apt install libncurses5
[ 99% 129266/129287] //frameworks/base/packages/SystemUI:SystemUI r8 [common]
Warning: Missing class android.compat.annotation.UnsupportedAppUsage (referenced from: void com.android.systemui.people.widget.PeopleBackupHelper.writeNewStateDescription(android.os.ParcelFileDescriptor))
Missing class android.support.annotation.Keep (referenced from: kotlinx.coroutines.android.AndroidExceptionPreHandler)
Missing class org.jetbrains.annotations.NotNull (referenced from: java.util.List com.android.keyguard.FontInterpolator$VarFontKey.sortedAxes and 4935 other contexts)
Missing class org.jetbrains.annotations.Nullable (referenced from: android.graphics.fonts.Font com.android.keyguard.FontInterpolator$InterpKey.l and 1143 other contexts)
Info: Stripped invalid locals information from 1 method.
Info in ./out/soong/.intermediates/frameworks/base/packages/SystemUI/SystemUI/android_common/combined/SystemUI.jar:kotlinx/coroutines/scheduling/WorkQueue.class:
Methods with invalid locals information:
void kotlinx.coroutines.scheduling.WorkQueue.offloadAllWork$kotlinx_coroutines_core(kotlinx.coroutines.scheduling.GlobalQueue)
Type information in locals-table is inconsistent. Cannot constrain type: BOTTOM (empty) for value: v15 by constraint INT.
Info: Some warnings are typically a sign of using an outdated Java toolchain. To fix, recompile the source with an updated toolchain.
[100% 129287/129287] Target vbmeta image: out/target/product/generic_x86_64/vbmeta.img
#### build completed successfully (56:40 (mm:ss)) ####
szhou@bc04:~/aosp/aosp$
一个简单的下代码,编译,每次总会遇到新问题,这次算是又盘完了