Skip to content
Latchkey

Android "AAPT2 aapt2 Daemon startup failed" in CI

AGP runs AAPT2 as a long-lived daemon to compile and link resources. When the AAPT2 executable cannot start (a missing shared library, a wrong-architecture binary, or a sandbox restriction), the daemon fails to launch and resource processing cannot proceed.

What this error means

The build fails with "AAPT2 aapt2 Daemon #0: Daemon startup failed" and often a linker error such as "error while loading shared libraries: libc++.so".

Android
> AAPT2 aapt2 Daemon #0: Daemon startup failed
  This should not happen under normal circumstances, please file an issue if it does.
  aapt2: error while loading shared libraries: libc++.so.1: cannot open shared object file

Common causes

A missing runtime library on a slim image

AAPT2 links against system libraries (such as libc++) that a minimal runner image does not provide.

A wrong-architecture or restricted AAPT2 binary

An AAPT2 built for a different architecture, or one the sandbox forbids executing, cannot start the daemon.

How to fix it

Install the missing runtime libraries

Add the system packages AAPT2 needs before the build.

Terminal
sudo apt-get update
sudo apt-get install -y libc++1 libstdc++6

Use a matching Build Tools and image

Run on a runner image whose architecture matches the SDK Build Tools, and install the Build Tools that ship the right AAPT2.

Terminal
sdkmanager "build-tools;34.0.0"

How to prevent it

  • Install the system libraries AAPT2 links against in custom images.
  • Match the runner architecture to the Android Build Tools.
  • Bake required runtime libraries into a reusable runner image.

Frequently asked questions

What causes ""AAPT2 aapt2 Daemon startup failed""?
AAPT2 links against system libraries (such as libc++) that a minimal runner image does not provide.
How do I fix "AAPT2 aapt2 Daemon startup failed"?
Add the system packages AAPT2 needs before the build.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card