Android Gradle Plugin (AGP) Version Compatibility
Problem Overview
When working with Android projects, you might encounter an error message similar to:
The project is using an incompatible version (AGP X.X.X) of the Android Gradle plugin. Latest supported version is AGP Y.Y.YThis error occurs when your Android Studio version doesn't support the Android Gradle Plugin (AGP) version specified in your project. This commonly happens when:
- Importing projects from GitHub or other sources
- Downgrading Android Studio to a previous version
- Opening projects created with newer Android Studio versions
- Having outdated Android Studio installation
Solutions
Option 1: Update Android Studio (Recommended)
The most straightforward solution is to update your Android Studio to the latest version:
Android Studio → Check for Updates → Update NowHelp → Check for Updates → Update NowTIP
For Mac users: Use Cmd + , to open Preferences, then navigate to Appearance & Behavior → System Settings → Updates
Updating ensures you have the latest AGP support and access to newest features.
Option 2: Modify AGP Version in Project Files
If you cannot update Android Studio, manually adjust the AGP version to match your IDE's supported version.
For Traditional build.gradle files:
// In project-level build.gradle
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:7.2.1' // Change to your supported version
// Other dependencies...
}
}For Kotlin DSL build.gradle.kts:
plugins {
id("com.android.application") version "7.2.2" // Your compatible version
// Other plugins...
}For projects using libs.versions.toml:
[versions]
agp = "8.2.2" # Change to your compatible version
[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }WARNING
When changing AGP versions, you may need to adjust other dependencies (like Kotlin version) to maintain compatibility.
Option 3: Using Android Studio's Project Structure
- Open File → Project Structure
- Select the Project section
- Choose a compatible AGP version from the dropdown menu
- Click OK and sync your project
Version Compatibility Reference
Android Studio and AGP versions must be compatible. Here's a general guideline (check Android Studio's official documentation for exact matches):
| Android Studio Version | Supported AGP Versions |
|---|---|
| Hedgehog (2023.1.1) | ~8.2.2 |
| Giraffe (2022.3.1) | ~8.1.0 |
| Flamingo (2022.2.1) | ~7.3.0 |
| Electric Eel (2022.1.1) | ~7.2.0 |
| Dolphin (2021.3.1) | ~7.1.0 |
INFO
Always check the official Android Studio and AGP compatibility table for exact version matching.
Best Practices
- Keep Android Studio updated to avoid compatibility issues
- Document AGP versions in team projects to ensure consistency
- Use version catalogs (libs.versions.toml) for easier version management
- Check compatibility before importing external projects
Troubleshooting Tips
If you continue experiencing issues:
- Invalidate caches: File → Invalidate Caches / Restart
- Clean project: Build → Clean Project, then Build → Rebuild Project
- Check Gradle wrapper: Ensure gradle-wrapper.properties uses a compatible Gradle version
DANGER
Avoid the nuclear option of completely uninstalling and reinstalling Android Studio unless absolutely necessary, as this is rarely required to resolve AGP version conflicts.
By following these steps, you should be able to resolve AGP version compatibility issues and continue working on your Android projects seamlessly.