简体   繁体   中英

Android 12/13 Signing OTA fails with error in sign_target_files_apks due to missing file vendor.img when vendor binaries are added

Attempting to build on OTA image for AOSP 12, the sign_target_files_apks utility fails due to missing vendor.img file. The error occurs only after vendor binaries are added. Same thing with AOSP 13, error occurs only after vendor binaries are added.

Target is Google Pixel 3a "Sargo" , OS is Ubuntu 18.04 LTS , AOSP version tag is android-12.1.0_r27 .

I added the correct device binaries downloaded from Google's website , compiled and flashed to a Pixel 3a device (codename Sargo) successfully.

Then attempted building an OTA package following google's documentation on Signing Builds for Release to generate the keys, Building OTA Packages to build the actual OTA package, and sign the package following Signing Builds for Release .

When I attempted to sign the OTA package by running the following (quoted from Signing Builds for Release ):

make dist
sign_target_files_apks \
-o \    # explained in the next section
--default_key_mappings ~/.android-certs out/dist/*-target_files-*.zip \
signed-target_files.zip

sign_target_files_apks throws an error:

build_super_image.py - WARNING : Skip building super image because the following images are missing from target files:
/tmp/targetfiles-1KVO0M/IMAGES/vendor.img

And shows a trace at the end:

Traceback (most recent call last):
  File "/home/dean/proj/aosp12/out/soong/host/linux-x86/bin/sign_target_files_apks/internal/stdlib/runpy.py", line 174, in _run_module_as_main
  File "/home/dean/proj/aosp12/out/soong/host/linux-x86/bin/sign_target_files_apks/internal/stdlib/runpy.py", line 72, in _run_code
  File "/home/dean/proj/aosp12/out/soong/host/linux-x86/bin/sign_target_files_apks/__main__.py", line 12, in <module>
  File "/home/dean/proj/aosp12/out/soong/host/linux-x86/bin/sign_target_files_apks/internal/stdlib/runpy.py", line 174, in _run_module_as_main
  File "/home/dean/proj/aosp12/out/soong/host/linux-x86/bin/sign_target_files_apks/internal/stdlib/runpy.py", line 72, in _run_code
  File "/home/dean/proj/aosp12/out/soong/host/linux-x86/bin/sign_target_files_apks/sign_target_files_apks.py", line 1420, in <module>
  File "/home/dean/proj/aosp12/out/soong/host/linux-x86/bin/sign_target_files_apks/sign_target_files_apks.py", line 1413, in main
  File "/home/dean/proj/aosp12/out/soong/host/linux-x86/bin/sign_target_files_apks/add_img_to_target_files.py", line 1039, in main
  File "/home/dean/proj/aosp12/out/soong/host/linux-x86/bin/sign_target_files_apks/add_img_to_target_files.py", line 985, in AddImagesToTargetFiles
  File "/home/dean/proj/aosp12/out/soong/host/linux-x86/bin/sign_target_files_apks/add_img_to_target_files.py", line 606, in CheckAbOtaImages
AssertionError: Failed to find vendor.img  

Some testing I've done revealed that the error occurs only after vendor binaries are added to the build, as instructed in Google's documentation . Executing sign_target_files_apks without adding vendor binaries finishes successfully. I attempted to reproduce the error on AOSP 13 with a different target device and achieved the same results: sign_target_files_apks error occurs only after vendor binaries are added.

I have found the solution:

There's a patch by PixelExperience, intended for AOSP 10, but applicable to AOSP 12. The patch can be found on Github and also on their Gerrit .

To elaborate further:

The patch modifies sign_target_files_apks.py located under build/make/tools/releasetools or build/tools/releasetools . You can modify either file, they are linked and changes reflect.

In function ProcessTargetFiles : Replace line if filename.startswith("IMAGES/"): with line if filename.startswith("IMAGES/") and not filename.endswith("vendor.img"):

In function main : Replace line new_args = ["--is_signing"] with line new_args = ["--is_signing", "--add_missing"]

Make sure to rebuild AOSP with make dist before you attempt to run sign_target_files_apks because it's path resolves soong out folder.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM