Exception handling when compiling Android system source code

Exception handling when compiling Android system source code

Prompt syntax error, as follows:

FAILED: out/target/product/generic/system-qemu.img
/bin/bash -c "(export SGDISK=out/host/linux-x86/bin/sgdisk SIMG2IMG=out/host/linux-x86/bin/simg2img;      device/generic/goldfish/tools/mk_combined_img.py -i out/target/product/generic/system-qemu-config.txt -o out/target/product/generic/system-qemu.img)"
  File "device/generic/goldfish/tools/mk_combined_img.py", line 48
    print "'%s' cannot be converted to int" % (line[2])
          ^
SyntaxError: invalid syntax

image-20230429204644867

I found some posts on the Internet, all of which are just to change device/generic/goldfish/tools/mk_combined_img.pythe content of the file directly. At this time, you will find that the modification may not work. The interpreter error will be reported again, and the reason is obvious at this time.

image-20230429205118541

reason

I use the Ubuntu system, and the python I installed is python3.10, and the reason for the error in the picture is a syntax error. device/generic/goldfish/tools/mk_combined_img.pyThe syntax used in is the syntax of python2, so we need to install python2 at this time. But python3 already exists in our system, so we need to install multiple environments at this time.

Enable universe repository

sudo apt-add-repository universe
sudo apt update

Install python2.7

sudo apt install python2-minimal

Check the python version after installation

python2 --version

image-20230429205522395

After the installation is complete, enter

Execute in the aosp directory

vim device/generic/goldfish/tools/mk_combined_img.py

Modify it as shown in the figure below, change python to python2, save and exit after the modification is complete.

image-20230429205730652

Re-run

make -j16

Finish

image-20230429205936677

Guess you like

Origin blog.csdn.net/qq_49619863/article/details/130443730