android build_error ai_generated true

Android resource linking failed. error: resource style/Theme.AppCompat not found

ID: android/aapt2-resource-linking-failed

Also available as: JSON · Markdown
85%Fix Rate
88%Confidence
3Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
8 active

Root Cause

AAPT2 cannot link a referenced resource. Missing dependency, wrong theme parent, or resource name typo.

generic

Workarounds

  1. 92% success Add the missing AppCompat/Material dependency
    implementation 'com.google.android.material:material:1.11.0'  // provides Material themes and styles

    Sources: https://developer.android.com/reference/

  2. 88% success Verify the parent theme exists in your dependencies
    Check styles.xml parent theme; ensure it matches an available theme from your dependencies
  3. 82% success Run AAPT2 with verbose logging to find exact missing resource
    ./gradlew assembleDebug --info 2>&1 | grep 'AAPT'  # shows exact resource and file with the error

Dead Ends

Common approaches that don't work:

  1. Disable AAPT2 (android.enableAapt2=false) 92% fail

    AAPT2 is mandatory since AGP 3.0+. The flag is ignored in modern versions.

  2. Copy missing resource definitions from library source code 78% fail

    Library resources should come from the dependency. Duplicating them causes version conflicts.