Android source code compilation failed without specific error message

error phenomenon

When compiling the Android source code, it fails to compile from time to time, and there is no specific error message. There is no specific error message in error.log / soong.log, which is the same as the information printed during make. See the figure below.
At this point, resync or restore changes are invalid.
insert image description here
error.log

FAILED: out/soong/.bootstrap/bin/soong_build out/soong/build.ninja
Outputs: out/soong/build.ninja
Error: exited with code: 1
Command: out/soong/.bootstrap/bin/soong_build -t -l out/.module_paths/Android.bp.list -b out/soong -n out -d out/soong/build.ninja.d -globFile out/soong/.bootstrap/build-globs.ninja -o out/soong/build.ninja Android.bp
Output:
Clang SA is not enabled
Killed

Solution

If this happens, one possible reason is that the swap partition is full.
When I encounter this kind of error, the swap seen by the following two methods is full. I saw that the memory is not very small, and thought that the swap partition would probably not be used, and the default value of swap (2G) was not modified. According to practical experience, 32G memory is not very rich for compiling Android source code. While compiling, we often open some development tools such as Android Studio, browser Chrome, etc., which consume a lot of memory.

solution one

Restart the computer and compile again to proceed normally.
When there are many open applications, the problem may occur again.

Solution two

Adjust the size of the swap partition.
According to general experience, the swap is set to about twice the size of the physical memory. For a computer with 32G memory, set the swap to 64G. The required size can be set according to actual needs.
By the way, swap is essentially a swap partition swapped out on the hard disk. If the physical memory is not enough, the data will be swapped to swap. The current high-speed solid-state hard drive is relatively cool to use as swap, but, but, but, because of frequent read and write, it may affect the life of the solid-state hard drive. If it’s your own computer, think about it, huh, huh

How to adjust the swap partition:

View swap partition

View via command line

$ free 
              total        used        free      shared  buff/cache   available
Mem:       32586296     3081844    10067916      959608    19436536    28078536
Swap:      62499996     1515520    60984476

View through the system monitor tool that comes with Ubuntu

insert image description here

Guess you like

Origin blog.csdn.net/yinminsumeng/article/details/129120073