[Android Q&A, Help & Troubleshooting] Deleted member 12232605:
Hello everyone!

Context

:

I am building LineageOS 14.1 for zeroltexx as per this guide, on an Arch Linux (Linux 5.18.14-arch1-1 x86_64) using OpenJDK 1.8.

The problem

:

The build is not exactly stuck on a single fatal error, but "brunch zeroltexx" proceeds a few items at a time (10-30 files out of 50,000 to be built), always ending along the lines of

[ 0% 64/39868] target Export Resources: framework-res (/home/dod/androi...t/target/common/obj/APPS/framework-res_intermediates/package-export.apk)
FAILED: /home/dod/android/lineage/out/target/common/obj/APPS/framework-res_intermediates/package-export.apk
/bin/bash -c "(touch /home/dod/android/lineage/out/target/common/obj/APPS/framework-res_intermediates/zipdummy ) && ((cd /home/dod/android/lineage/out/target/common/obj/APPS/framework-res_intermediates/ && jar cf package-export.apk zipdummy) ) && (zip -qd /home/dod/android/lineage/out/target/common/obj/APPS/framework-res_intermediates/package-export.apk zipdummy ) && (rm /home/dod/android/lineage/out/target/common/obj/APPS/framework-res_intermediates/zipdummy ) && (/home/dod/android/lineage/out/host/linux-x86/bin/aapt package -u -x --private-symbols com.android.internal -z --pseudo-localize -M frameworks/base/core/res/AndroidManifest.xml -S device/samsung/zero-common/overlay/frameworks/base/core/res/res -S device/samsung/zero-common/overlay-gsm/frameworks/base/core/res/res -S vendor/cm/overlay/common/frameworks/base/core/res/res -S frameworks/base/core/res/res -A frameworks/base/core/res/assets --min-sdk-version 25 --target-sdk-version 25 --product default --version-code 25 --version-name 7.1.2 --skip-symbols-without-default-localization -F /home/dod/android/lineage/out/target/common/obj/APPS/framework-res_intermediates/package-export.apk )"
vendor/cm/overlay/common/frameworks/base/core/res/res/drawable-xxhdpi/default_wallpaper.png: error: Duplicate file.
vendor/cm/overlay/common/frameworks/base/core/res/res/drawable-xxhdpi-v4/default_wallpaper.png: Original is here. The version qualifier may be implied.
[ 0% 64/39868] host Java: hierarchyviewer (/home/dod/android/lineage/out/host/common/obj/JAVA_LIBRARIES/hierarchyviewer_intermediates/classes)
[ 0% 64/39868] host Java: ahat (/home/dod/android/lineage/out/host/common/obj/JAVA_LIBRARIES/ahat_intermediates/classes)
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
[ 0% 64/39868] host Java: dx (/home/dod/android/lineage/out/host/common/obj/JAVA_LIBRARIES/dx_intermediates/classes)
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
[ 0% 64/39868] Building Kernel Headers
make: Entering directory '/home/dod/android/lineage/kernel/samsung/exynos7420'
GEN /home/dod/android/lineage/out/target/product/zeroltexx/obj/KERNEL_OBJ/Makefile
Kconfig:15:warning: environment variable ANDROID_MAJOR_VERSION undefined
arch/arm64/configs/lineageos_zeroltexx_defconfig:621:warning: override: reassigning to symbol INET_DIAG
#
# configuration written to .config
#
make: Leaving directory '/home/dod/android/lineage/kernel/samsung/exynos7420'
make: Entering directory '/home/dod/android/lineage/kernel/samsung/exynos7420'
CHK include/generated/uapi/linux/version.h
INSTALL include/asm-generic (34 files)
INSTALL include/drm (17 files)
INSTALL include/linux/byteorder (2 files)
INSTALL include/mtd (5 files)
INSTALL include/linux/caif (2 files)
INSTALL include/rdma (6 files)
INSTALL include/linux/can (5 files)
INSTALL include/scsi/fc (4 files)
INSTALL include/linux/dvb (8 files)
INSTALL include/sound (10 files)
INSTALL include/scsi (3 files)
INSTALL include/video (3 files)
INSTALL include/linux/hdlc (1 file)
INSTALL include/linux/hsi (1 file)
INSTALL include/xen (2 files)
INSTALL include/linux/isdn (1 file)
INSTALL include/uapi (0 file)
INSTALL include/linux/mmc (1 file)
INSTALL include/linux/netfilter/ipset (4 files)
INSTALL include/linux/netfilter_arp (2 files)
INSTALL include/linux/netfilter_bridge (18 files)
INSTALL include/linux/netfilter_ipv4 (10 files)
INSTALL include/linux/netfilter_ipv6 (12 files)
INSTALL include/linux/netfilter (78 files)
INSTALL include/linux/nfsd (5 files)
INSTALL include/linux/raid (2 files)
INSTALL include/linux/spi (1 file)
INSTALL include/linux/sunrpc (1 file)
INSTALL include/linux/tc_act (7 files)
INSTALL include/linux/tc_ematch (4 files)
INSTALL include/linux/usb (11 files)
INSTALL include/linux/wimax (1 file)
INSTALL include/linux (388 files)
INSTALL include/asm (33 files)
make: Leaving directory '/home/dod/android/lineage/kernel/samsung/exynos7420'
ninja: build stopped: subcommand failed.
make: *** [build/core/ninja.mk:152: ninja_wrapper] Error 1
make: Leaving directory '/home/dod/android/lineage'

#### make failed to build some targets (03:09 (mm:ss)) ####

I could probably wrap brunch in a while loop and be done with it, but that would be much more time-intensive than if the build could run continuously.

Note that the line

vendor/cm/overlay/common/frameworks/base/core/res/res/drawable-xxhdpi/default_wallpaper.png: error: Duplicate file.

appears because I have created 4 new folders named drawable-hdpi-v4, drawable-xhdpi-v4 etc to which I copied the contents of drawable-hdpi, drawable-xhdpi etc. This was to correct an earlier error about default.png not being found for drawable-hdpi-v4 and the others:

[ 0% 78/32836] target Export Resou...s_intermediates/package-export.apk)
warning: string 'candidates_style' has no default translation.
warning: string 'gsm_alphabet_default_charset' has no default translation.
warning: string 'wfcSpnFormat' has no default translation.
nothing matches overlay file default_wallpaper.png, for flavor hdpi-v4
nothing matches overlay file default_wallpaper.png, for flavor xhdpi-v4
nothing matches overlay file default_wallpaper.png, for flavor xxhdpi-v4
nothing matches overlay file default_wallpaper.png, for flavor xxxhdpi-v4
ninja: build stopped: subcommand failed.
make: *** [build/core/ninja.mk:152: ninja_wrapper] Error 1
make: Leaving directory '/home/dod/android/lineage'

#### make failed to build some targets (03:31 (mm:ss)) ####

The build runs for longer upon deleting these drawable-*hdpi-v4 folders I created, but only for a few hundred items before failing anyway.

Leads

:

After some research, these sorts of errors are often related to running out of memory. But I have 8GB RAM and an additional 8GB from zram, and RAM usage never actually climbs above 4GB.

The whole building-a-few-items-and-failing routine happens very quickly, but I did spot in htop a few processes that start with "javac -J-Xmx1024M ...". This may have something to do with the following note in the LineageOS build guide:

But setting -Xmx4G and even 8G does not make a difference. I also tried setting a higher max memory in _JAVA_OPTIONS, and this is explicitly acknowledged during build ("Picked up _JAVA_OPTIONS: -Xmx16G"), but I still see those "javac -J-Xmx1024m ..." in htop, and total RAM usage is still below 4GB.

I also cannot get the build to use the number of cores I want. I have 4, and it uses all of them even if I build with make -j1. The issue appears similar to this thread, particularly

I'm familiar with Linux, but new to building ROMs and know nothing about Java, so any ideas would be appreciated. I'm happy to add complete logs and other information as needed.