AOSP ERROR: Dex2oat failed to compile a boot image.It is likely that the boot classpath is inconsistent

1.2k views Asked by At

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

  1. Tried running build with additional flags: ALLOW_MISSING_DEPENDENCIES=true WITH_DEXPREOPT=false ART_BOOT_IMAGE_EXTRA_ARGS="--runtime-arg -verbose:verifier" m -j4
  2. Tried remove flags ("-msse4.2" and "-mpopcnt") in art/build/Android.bp (https://i.stack.imgur.com/39O63.png)
2

There are 2 answers

0
Vitalii Bonar On

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:

  1. In build/core/board_config.mk set WITH_DEXPREOPT to false build/core/board_config.mk
  2. Silence the error in build/core/dex_preopt_config.mk by removing $(call pretty-error, DEXPREOPT must be enabled for user and userdebug builds) build/core/dex_preopt_config.mk
0
MKH Russell On

It seems, in Ubuntu 22.04 LTS with kernel version 6.x.x creating some problem or it is not compatible to the build system. My problem was fixed when I downgraded my build machine's kernel version (to: 5.15.0-84-generic). Take look here: https://stackoverflow.com/a/77203755/6037446