The document recommends using Ubuntu 18.04 LTS for compilation, but since Ubuntu 18.04 has already stopped receiving technical support, it's better to transition to Ubuntu 22.04 as soon as possible. There are many benefits to upgrading to 22.04, such as:You will be able to find solutions to problems more easily, as the community and documentation are more up-to-date. Wi-Fi and touchpad driver support is better for newer computers. Upgrading to 22.04 ensures better compatibility and long-term support for modern hardware.
Adjusting the System Swap Space First, let's discuss the system environment requirements. 16GB of RAM is the minimum, and keep in mind that the performance of a virtual machine during compilation cannot be compared to that of a physical machine. If your computer has 16GB of RAM but you're using a virtual machine for compilation, it may still struggle since Windows itself uses a significant portion of memory in idle state. It could be challenging to handle the load. When compiling Android, it's essential to adjust the swap space in Ubuntu, as the default swap space of 2GB is definitely insufficient (especially for systems with 16GB of RAM). It's recommended to increase the swap space to 8GB or even 16GB. Ideally, adjust the swap space before starting the compilation process to avoid errors later on during the build.
Don’t Just Copy Commands You should not blindly copy the commands from the documentation; it's important to understand each step's meaning. When compiling the Android SDK system, the commands can often be adjusted to fit your system's specific needs. Understanding the logic behind each command will help you troubleshoot and optimize your process more effectively.
cd u-boot && ./make.sh rk3566 && cd ../kernel && make clean && make distclean && make ARCH=arm64 tspi_defconfig rk356x_evb.config android-11.config && make ARCH=arm64 tspi-rk3566-user-v10.img -j$(nproc) && cd .. && source build/envsetup.sh && lunch rk3566_tspi-userdebug && make installclean -j$(nproc) && make -j$(nproc) && ./mkimage.sh
Try executing echo $(nproc)
to see the result. That should help explain why this alternative is more applicable.
- Python The issue with compiling is mainly related to the Python version. On Ubuntu 18.04, running the command
sudo apt install python
installs Python 2.7. However, in Ubuntu 22.04, thepython
command by default points topython3
.- Python 2 has reached its end of life as of January 1, 2020, meaning it no longer receives security updates or new features.
- Python 3 comes with many improvements and new features. The syntax is clearer, and the error messages are more user-friendly.
- The following command is suitable for Ubuntu 22.04:
#Android compilation environment installation
sudo apt install -y git python2.7 make openjdk-8-jdk git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev libgl1-mesa-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev libxml2-utils xsltproc unzip python2.7 bc imagemagick ccache schedtool libssl-dev libncurses5-dev clang
2
For Linux commands, directly copying them from the documentation should work fine. Install the Android compilation environment first, and then move on to the Linux setup without any issues.
A. If you encounter issues when checking out the repo, refer to Wu Gong’s tutorial on version control to switch to Python 2.6.
B. If you encounter another issue when switching branches during Android repo compilation, you might see the following message:
In summary, the issue is: ModuleNotFoundError: No module named 'formatter'
The formatter module has been deprecated in Python 3.4+, and it seems that manually switching to Python 2.6 doesn’t resolve it either.
According to the error message and following the solution from the link below, simply modify the help.py file as indicated.
【help.py】Download
📌 Download Center (click to go)
📌 Go to Download Center
->Baidu Netdisk Resource Content
->Chapter 03. Documentation Manuals
-> [User-contributed] Document Attachments
->【User-contributed】Ubuntu 22.04 LTS Compilation
folder.
- Linux Compilation Issues If you encounter issues (click to go), you can follow these solutions:
- The issue is caused by multiple definitions in stackoverflow.com.
- The solution is: Based on the error message, locate the corresponding folder and modify the mksquashfs.h file by adding extern before the corresponding line at line 136. extern