Resolving Compile SDK Conflict with Androidx.Activity 1.8.0
Problem Statement
When building an Android project using the com.google.android.material:material:1.10.0
dependency, you may encounter this critical build error:
An issue was found when checking AAR metadata:
1. Dependency 'androidx.activity:activity:1.8.0' requires libraries and applications that
depend on it to compile against version 34 or later of the
Android APIs.
:app is currently compiled against android-33.
Also, the maximum recommended compile SDK version for Android Gradle
plugin 8.0.2 is 33.
This occurs because the Material library v1.10.0 includes a dependency on Androidx Activity v1.8.0, which mandates compiling against Android API Level 34 (Android 14) or higher. However, your project is configured for compileSdk 33
(Android 13), creating a version mismatch. The Android Gradle plugin (v8.0.2) also caps the recommended compile SDK at 33, compounding the issue.
Recommended Solution: Update Compile SDK
The optimal solution matches Android's official recommendation: upgrade your project to use API Level 34.
Implementation Steps
- Open module-level
build.gradle
in your app module - Update
compileSdk
andtargetSdk
values:
android {
namespace 'com.your.app'
compileSdk 34 // Update from 33
defaultConfig {
applicationId "com.your.app"
minSdk 24
targetSdk 34 // Update from 33
// ... other configurations
}
// ... remaining configurations
}
- Update Android Gradle Plugin in project-level
build.gradle
:
// Top-level build.gradle
plugins {
id 'com.android.application' version '8.2.0' // or higher
// ...
}
- Sync Gradle and rebuild your project
Recommended Action Flow
Alternative Solution: Downgrade Material Library
If temporarily upgrading SDK isn't viable, downgrade the Material library to a version compatible with API 33:
dependencies {
// Replace with:
implementation 'com.google.android.material:material:1.9.0'
// Other dependencies remain unchanged
}
Compatibility Notice
Material Version | Required compileSdk | Notes |
---|---|---|
1.10.0 | 34+ | Requires Android 14 API |
1.9.0 | 33 | Compatible with Android 13 |
1.8.0 | 33 | Last of v1.8 series |
Explanation
Why This Happens
Android dependencies progressively adopt newer platform features. The androidx.activity:activity:1.8.0
contains Android 14-specific bytecode, triggering an enforcement mechanism in the Android build system. The dependency chain looks like:
material:1.10.0
→ activity:1.8.0
→ Requires compileSdk 34
Solution Comparisons
Approach | Pros | Cons |
---|---|---|
Update to compileSdk 34 | Future-proof, supports latest features | Requires compatibility testing |
Downgrade Material | Quick fix, no SDK update needed | Missing latest Material Design features |
Exclude activity module | Avoids SDK upgrade | May cause runtime crashes |
Avoid Anti-Patterns
Never use these problematic workarounds:
# gradle.properties - Hides actual issue
android.suppressUnsupportedCompileSdk=34
// Arbitrary dependency exclusion - unstable
implementation("com.google.android.material:material:1.10.0") {
exclude(group: "androidx.activity", module: "activity")
}
Verification Steps
After applying the solution:
- Clean project (Build > Clean Project)
- Invalidate caches (File > Invalidate Caches)
- Verify SDK settings in build.gradle
- Sync project with Gradle files
- Build project (Build > Make Project)
Expected result: The dependency error disappears, and your app builds successfully.
Tip: Always match major version numbers between AndroidX libraries (e.g., Material v1.9.x works best with AppCompat v1.6.x).