What is Android Gradle Plugin (AGP) to version 8.9.1 in android/settings.gradle it will look like id "com.android.application" version '8.9.1' apply false
#android
Answer
Overview
The Android Gradle Plugin (AGP) is the build system plugin that integrates Android-specific build features into Gradle. It handles compiling, packaging, signing, and optimizing your Android app.
Where AGP is Configured
In Flutter projects using the new settings.gradle format (Flutter 3.16+):
gradle// android/settings.gradle pluginManagement { def flutterSdkPath = { def properties = new Properties() file("local.properties").withInputStream { properties.load(it) } def flutterSdkPath = properties.getProperty("flutter.sdk") assert flutterSdkPath != null, "flutter.sdk not set in local.properties" return flutterSdkPath }() includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") repositories { google() mavenCentral() } } plugins { id "dev.flutter.flutter-plugin-loader" version "1.0.0" id "com.android.application" version "8.9.1" apply false // ← AGP version id "org.jetbrains.kotlin.android" version "2.1.0" apply false }
Older Format (build.gradle)
gradle// android/build.gradle (older Flutter projects) buildscript { dependencies { classpath "com.android.tools.build:gradle:8.9.1" } }
What AGP Does
| Feature | Description |
|---|---|
| Compiles resources | Processes XML layouts, drawables, strings |
| Generates R.java | Gives code access to resources by ID |
| Handles variants | Debug, release, custom build types |
| Manages signing | Signs APK/AAB for release |
| Optimizes | ProGuard/R8 minification, shrinking |
| Package types | Produces APK and AAB files |
| Native libs | Integrates JNI/NDK builds |
Updating AGP Version
gradle// In android/settings.gradle id "com.android.application" version "8.9.1" apply false
Then sync:
bashflutter clean flutter pub get
AGP and Gradle Compatibility
| AGP | Min Gradle | Min Android Studio |
|---|---|---|
| 8.9.1 | 8.11.1 | Ladybug (2024.2.1) |
| 8.7.x | 8.9 | Ladybug |
| 8.4.x | 8.6 | Jellyfish |
Common Error on AGP Mismatch
textERROR: The project is using an incompatible version (AGP 8.9.1) of the Android Gradle plugin. Minimum supported version is AGP 7.0.0.
bash# Fix: ensure Gradle wrapper is on compatible version # android/gradle/wrapper/gradle-wrapper.properties distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-all.zip
Key Point: Always keep AGP and Gradle versions in sync according to the compatibility matrix. An incompatible pair causes build failures.