I'm trying to build android 12. I was using Ubuntu 22.04.2 where it worked successfully. Now I've installed a fresh Ubuntu 22.04.3 which is using a new kernel and I started getting this error:
ERROR: Dex2oat failed to compile a boot image.It is likely that the boot classpath is inconsistent.Rebuild with ART_BOOT_IMAGE_EXTRA_ARGS="--runtime-arg -verbose:verifier" to see verification errors.
I've seen this similar issue Android dex2oat build:ERROR: Dex2oat failed to compile a boot image - Nothing worked for me from this thread
- Tried running build with additional flags:
ALLOW_MISSING_DEPENDENCIES=true WITH_DEXPREOPT=false ART_BOOT_IMAGE_EXTRA_ARGS="--runtime-arg -verbose:verifier" m -j4 - Tried remove flags ("-msse4.2" and "-mpopcnt") in art/build/Android.bp (https://i.stack.imgur.com/39O63.png)
So after some digging AOSP code I've came up with this workaround. Note that I don't think its a solution - just a workaround. Basically it figures out that WITH_DEXPREOPT is overriden in build scripts. In my AOSP version it was in build/core/board_config.mk
Workaround:
build/core/board_config.mksetWITH_DEXPREOPTto false build/core/board_config.mkbuild/core/dex_preopt_config.mkby removing$(call pretty-error, DEXPREOPT must be enabled for user and userdebug builds)build/core/dex_preopt_config.mk