The Gradle Wrapper alone is insufficient to prevent Android Gradle Plugin (AGP) version shifts. While the Wrapper locks the Gradle distribution (the build tool), the AGP is a plugin applied to that tool. Because Android Studio often prompts users to upgrade the plugin to match the IDE's capabilities, the AGP version can diverge across a team if not explicitly locked in the build configuration.
The Mechanism for AGP Consistency
To ensure consistency, the AGP version must be declared as a hard-coded dependency within the project's build scripts and committed to version control. This forces the IDE to use the specified version regardless of the installed Android Studio version, provided the IDE version is compatible with that specific AGP release.
Recommended Locking Strategies
Depending on your Gradle version and project structure, use one of the following methods to lock the AGP version:
- Version Catalog (libs.versions.toml): The modern standard for centralized dependency management. Define the AGP version in the
[versions] block and reference it in the [plugins] block.
- Buildscript Classpath: In older projects, the AGP version is locked in the top-level
build.gradle file within the dependencies block of the buildscript section.
- Plugins DSL: Using the
plugins { id 'com.android.application' version 'X.Y.Z' apply false } syntax in the root build file.
Fact vs. IDE Behavior
| Feature |
Gradle Wrapper |
AGP Declaration |
| Locks |
Gradle Distribution (e.g., 8.5) |
Build Logic Plugin (e.g., 8.2.0) |
| Scope |
Environment/Runtime |
Project Logic/API |
| IDE Interaction |
Rarely prompts for change |
Frequently prompts via Upgrade Assistant |
Verification Steps
To verify that your environment is locked and consistent, run the following checks:
- Check
gradle/wrapper/gradle-wrapper.properties to ensure the distributionUrl is identical for all team members.
- Inspect your version catalog or root
build.gradle to ensure the AGP version is a static string, not a dynamic range (e.g., use 8.2.0, not 8.2+).
- Open Project Structure > Project in Android Studio to confirm the "Android Gradle Plugin Version" matches the committed code.
Diagnostic Note: Are you using a monorepo with multiple modules that may have conflicting plugin declarations? This would require a centralized version catalog to maintain consistency.