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".
> 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 fileCommon 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.
sudo apt-get update
sudo apt-get install -y libc++1 libstdc++6Use 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.
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.