Skip to content
Latchkey

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.

Xamarin.Android
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

  1. Read the APT2 line to find the exact file and reason.
  2. Rename files to lowercase/underscore and correct invalid XML.
  3. Add or fix any referenced resource that is missing.
Terminal
# rename the offending file
git mv "Resources/drawable/My Icon.png" Resources/drawable/my_icon.png

Build clean to avoid stale resource caches

Clear intermediate resource output so a stale cached resource does not mask the fix.

Terminal
dotnet clean
dotnet build -f net8.0-android -c Release

How 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.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →