MAUI Android "APT2 ... resource ... failed" in CI
AAPT2 compiles and links Android resources (drawables, layouts, values). An APT2 error means a resource file is invalid, mis-named, or references a missing resource, so the Android resource step fails the build.
What this error means
A MAUI Android build fails with "error APT2 ..." pointing at a resource path, such as an invalid file name, a failed link, or a resource not found.
error APT2 0: file failed to compile. Resources/drawable/My Icon.png:
Invalid file name: must contain only lowercase letters, digits or underscore.
error APT2: Android resource linking failed.Common causes
An invalid resource file name or content
Android resource names must be lowercase with digits or underscores; a space, uppercase, or malformed XML makes AAPT2 reject the file.
A reference to a resource that does not exist
A layout or values file references a drawable, string, or attribute that is missing, so resource linking fails.
How to fix it
Fix the offending resource
- Read the APT2 line to find the exact file and reason.
- Rename files to lowercase/underscore and correct invalid XML.
- Add or fix any referenced resource that is missing.
# rename the offending file
git mv "Resources/drawable/My Icon.png" Resources/drawable/my_icon.pngBuild clean to avoid stale resource caches
Clear intermediate resource output so a stale cached resource does not mask the fix.
dotnet clean
dotnet build -f net8.0-android -c ReleaseHow to prevent it
- Keep Android resource names lowercase with digits or underscores.
- Validate referenced drawables and strings exist before commit.
- Build the Android target locally to catch APT2 issues early.