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
I found some posts on the Internet, all of which are just to change device/generic/goldfish/tools/mk_combined_img.py
the 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.
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.py
The 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
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.
Re-run
make -j16
Finish