Question #146EasyNative Integration

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

FeatureDescription
Compiles resourcesProcesses XML layouts, drawables, strings
Generates R.javaGives code access to resources by ID
Handles variantsDebug, release, custom build types
Manages signingSigns APK/AAB for release
OptimizesProGuard/R8 minification, shrinking
Package typesProduces APK and AAB files
Native libsIntegrates JNI/NDK builds

Updating AGP Version

gradle
// In android/settings.gradle
id "com.android.application" version "8.9.1" apply false

Then sync:

bash
flutter clean
flutter pub get

AGP and Gradle Compatibility

AGPMin GradleMin Android Studio
8.9.18.11.1Ladybug (2024.2.1)
8.7.x8.9Ladybug
8.4.x8.6Jellyfish

Common Error on AGP Mismatch

text
ERROR: 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.