From 6e34dcea479d835dc2493af56800d4a0f214885c Mon Sep 17 00:00:00 2001 From: Joachim Tobias Nohl <43643339+nohli@users.noreply.github.com> Date: Fri, 3 Jul 2026 02:19:59 +0400 Subject: [PATCH 01/10] Migrate plugin Gradle to built-in Kotlin --- android/build.gradle | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 701bcac..806c90f 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,19 +1,6 @@ group = "dev.fluttercommunity.android_id" version = "1.0-SNAPSHOT" -buildscript { - ext.kotlin_version = "2.1.0" - repositories { - google() - mavenCentral() - } - - dependencies { - classpath("com.android.tools.build:gradle:8.7.2") - classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version") - } -} - allprojects { repositories { google() @@ -22,7 +9,11 @@ allprojects { } apply plugin: "com.android.library" -apply plugin: "kotlin-android" + +def agpMajor = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize(".")[0] as int +if (agpMajor < 9) { + apply plugin: "kotlin-android" +} android { if (project.android.hasProperty("namespace")) { @@ -36,10 +27,6 @@ android { targetCompatibility = JavaVersion.VERSION_17 } - kotlinOptions { - jvmTarget = "17" - } - sourceSets { main.java.srcDirs += "src/main/kotlin" test.java.srcDirs += "src/test/kotlin" @@ -66,3 +53,9 @@ android { } } } + +kotlin { + compilerOptions { + jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17 + } +} From e38e4c0d4bddbbab90bd85751a447c56d49f7633 Mon Sep 17 00:00:00 2001 From: Joachim Tobias Nohl <43643339+nohli@users.noreply.github.com> Date: Fri, 3 Jul 2026 02:21:13 +0400 Subject: [PATCH 02/10] Migrate example app to built-in Kotlin --- example/android/app/build.gradle | 13 +++++++------ .../gradle/wrapper/gradle-wrapper.properties | 2 +- example/android/settings.gradle | 3 +-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 3ab4a50..5bed1cb 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -1,7 +1,6 @@ plugins { id "com.android.application" - id "kotlin-android" - // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. + // The Flutter Gradle Plugin must be applied after the Android Gradle plugin. id "dev.flutter.flutter-gradle-plugin" } @@ -33,10 +32,6 @@ android { targetCompatibility = JavaVersion.VERSION_17 } - kotlinOptions { - jvmTarget = "17" - } - defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId = "dev.fluttercommunity.android_id_example" @@ -60,3 +55,9 @@ android { flutter { source = "../.." } + +kotlin { + compilerOptions { + jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17 + } +} diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties index 6b74f0f..bdc0141 100644 --- a/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/example/android/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.1-bin.zip diff --git a/example/android/settings.gradle b/example/android/settings.gradle index 72e8d42..6464403 100644 --- a/example/android/settings.gradle +++ b/example/android/settings.gradle @@ -18,8 +18,7 @@ pluginManagement { plugins { id "dev.flutter.flutter-plugin-loader" version "1.0.0" - id "com.android.application" version "8.7.2" apply false - id "org.jetbrains.kotlin.android" version "2.1.0" apply false + id "com.android.application" version "9.1.1" apply false } include ":app" From 8bdc1b9f7ab59b887f6867064f797a9cdbc3c482 Mon Sep 17 00:00:00 2001 From: Joachim Tobias Nohl <43643339+nohli@users.noreply.github.com> Date: Fri, 3 Jul 2026 02:21:49 +0400 Subject: [PATCH 03/10] Bump built-in Kotlin release to 0.5.2 --- CHANGELOG.md | 13 +++++++++++++ example/pubspec.lock | 2 +- pubspec.yaml | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a712696..5d930ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,16 @@ +## 0.5.2 + +* Support Android Gradle Plugin 9 and Flutter's built-in Kotlin mode while keeping + AGP 8 and Flutter's temporary `android.builtInKotlin=false` opt-out working. +* Stop declaring plugin-owned Android Gradle Plugin and Kotlin Gradle Plugin classpaths. +* Update the example Android app to Android Gradle Plugin 9.1.1. +* Tested the example integration test with Flutter 3.44.0 and 3.44.4 on AGP 9 + opt-out mode, and Flutter 3.32.8, 3.35.7, and 3.41.9 on AGP 8 legacy mode. +* Verified AGP 9 built-in Kotlin mode with a release build; Flutter's current + `integration_test` Android package still blocks a full opt-in integration test. +* Thanks to @raph5640, @kururu-abdo, @Joschiller, and @iamnfinity for reporting + the AGP 9 build problem. + ## 0.5.1 * Add integration tests to verify plugin functionality across Android API levels diff --git a/example/pubspec.lock b/example/pubspec.lock index b750e42..34a9956 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -7,7 +7,7 @@ packages: path: ".." relative: true source: path - version: "0.5.1" + version: "0.5.2" async: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 0fb9dc2..a49f986 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -13,7 +13,7 @@ topics: - android - native -version: 0.5.1 +version: 0.5.2 environment: sdk: '>=3.0.0 <4.0.0' From bf2c3e15a34677c96c35a263547cf878cf631560 Mon Sep 17 00:00:00 2001 From: Joachim Tobias Nohl <43643339+nohli@users.noreply.github.com> Date: Fri, 3 Jul 2026 02:27:29 +0400 Subject: [PATCH 04/10] Opt example out of AGP new DSL --- example/android/gradle.properties | 1 + 1 file changed, 1 insertion(+) diff --git a/example/android/gradle.properties b/example/android/gradle.properties index 3b5b324..b942162 100644 --- a/example/android/gradle.properties +++ b/example/android/gradle.properties @@ -1,3 +1,4 @@ org.gradle.jvmargs=-Xmx4G -XX:+HeapDumpOnOutOfMemoryError android.useAndroidX=true android.enableJetifier=true +android.newDsl=false From f91b1c8e26eeb87e14d933e28b5c30a3e55f2de0 Mon Sep 17 00:00:00 2001 From: Joachim Tobias Nohl <43643339+nohli@users.noreply.github.com> Date: Fri, 3 Jul 2026 02:44:07 +0400 Subject: [PATCH 05/10] Document AGP 9 compatibility guidance --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index 842b8f1..7260e2c 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,23 @@ try { **Note:** `getId()` returns `null` on non-Android platforms (iOS, Web, etc.). On Android, it throws `MissingPluginException` if the plugin is not properly registered (see more [below](https://pub.dev/packages/android_id#troubleshooting)). +## Android build compatibility + +`android_id` supports Android Gradle Plugin 9 and Flutter's built-in Kotlin mode. +It also keeps working with AGP 8 and Flutter's temporary +`android.builtInKotlin=false` opt-out. + +The plugin no longer provides its own Android Gradle Plugin or Kotlin Gradle +Plugin classpaths. It only applies the Kotlin Gradle Plugin when the host build +still needs it. This fixes errors such as: + +```text +The 'org.jetbrains.kotlin.android' plugin is no longer required for Kotlin +support since AGP 9.0. +``` + +Most Flutter apps should not need app-code changes. + ## Important Please note that on `Android 8` and above, the `Android ID` is not unique per device, but also per signing key the app was built with: From 6175e73e797f69a63197b3d32f73abcccf4503ca Mon Sep 17 00:00:00 2001 From: Joachim Tobias Nohl <43643339+nohli@users.noreply.github.com> Date: Fri, 3 Jul 2026 04:11:29 +0400 Subject: [PATCH 06/10] Pub get with Flutter 3.44.4 --- example/pubspec.lock | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/example/pubspec.lock b/example/pubspec.lock index 34a9956..fcd208e 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -28,10 +28,10 @@ packages: dependency: transitive description: name: characters - sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803 + sha256: faf38497bda5ead2a8c7615f4f7939df04333478bf32e4173fcb06d428b5716b url: "https://pub.dev" source: hosted - version: "1.4.0" + version: "1.4.1" clock: dependency: transitive description: @@ -133,26 +133,26 @@ packages: dependency: transitive description: name: matcher - sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2 + sha256: dc0b7dc7651697ea4ff3e69ef44b0407ea32c487a39fff6a4004fa585e901861 url: "https://pub.dev" source: hosted - version: "0.12.17" + version: "0.12.19" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec + sha256: "9c337007e82b1889149c82ed242ed1cb24a66044e30979c44912381e9be4c48b" url: "https://pub.dev" source: hosted - version: "0.11.1" + version: "0.13.0" meta: dependency: transitive description: name: meta - sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c + sha256: "1741988757a65eb6b36abe716829688cf01910bbf91c34354ff7ec1c3de2b349" url: "https://pub.dev" source: hosted - version: "1.16.0" + version: "1.18.0" path: dependency: transitive description: @@ -234,10 +234,10 @@ packages: dependency: transitive description: name: test_api - sha256: "522f00f556e73044315fa4585ec3270f1808a4b186c936e612cab0b565ff1e00" + sha256: "949a932224383300f01be9221c39180316445ecb8e7547f70a41a35bf421fb9e" url: "https://pub.dev" source: hosted - version: "0.7.6" + version: "0.7.11" vector_math: dependency: transitive description: @@ -263,5 +263,5 @@ packages: source: hosted version: "3.1.0" sdks: - dart: ">=3.8.0 <4.0.0" + dart: ">=3.10.0-0 <4.0.0" flutter: ">=3.18.0-18.0.pre.54" From c0dbc9d580b839d205fc703d55fa0151b075f7dd Mon Sep 17 00:00:00 2001 From: Joachim Tobias Nohl <43643339+nohli@users.noreply.github.com> Date: Fri, 3 Jul 2026 04:28:48 +0400 Subject: [PATCH 07/10] Support built-in Kotlin opt-out --- android/build.gradle | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 806c90f..1cdb33c 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -10,9 +10,17 @@ allprojects { apply plugin: "com.android.library" -def agpMajor = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize(".")[0] as int -if (agpMajor < 9) { - apply plugin: "kotlin-android" +def agpMajor = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')[0] as int +boolean hasBuiltInKotlinSupport = agpMajor >= 9 + +def builtInKotlinProperty = findProperty('android.builtInKotlin') +boolean isBuiltInKotlinEnabled = builtInKotlinProperty == null || + builtInKotlinProperty.toString().toBoolean() + +boolean shouldApplyKotlinGradlePlugin = !hasBuiltInKotlinSupport || !isBuiltInKotlinEnabled + +if (shouldApplyKotlinGradlePlugin) { + apply plugin: 'kotlin-android' } android { From f2ad22cad4c99fba05f5b7bb3932f58f958aa7d0 Mon Sep 17 00:00:00 2001 From: Joachim Tobias Nohl <43643339+nohli@users.noreply.github.com> Date: Fri, 3 Jul 2026 06:47:43 +0400 Subject: [PATCH 08/10] Remove example AGP new DSL opt-out --- example/android/gradle.properties | 1 - 1 file changed, 1 deletion(-) diff --git a/example/android/gradle.properties b/example/android/gradle.properties index b942162..3b5b324 100644 --- a/example/android/gradle.properties +++ b/example/android/gradle.properties @@ -1,4 +1,3 @@ org.gradle.jvmargs=-Xmx4G -XX:+HeapDumpOnOutOfMemoryError android.useAndroidX=true android.enableJetifier=true -android.newDsl=false From cb41cdb5f2056fbb9f5a1b7fdca676c6f0baa438 Mon Sep 17 00:00:00 2001 From: Joachim Tobias Nohl <43643339+nohli@users.noreply.github.com> Date: Fri, 3 Jul 2026 06:52:24 +0400 Subject: [PATCH 09/10] Clarify changelog test matrix --- CHANGELOG.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d930ad..58797b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,10 +4,16 @@ AGP 8 and Flutter's temporary `android.builtInKotlin=false` opt-out working. * Stop declaring plugin-owned Android Gradle Plugin and Kotlin Gradle Plugin classpaths. * Update the example Android app to Android Gradle Plugin 9.1.1. -* Tested the example integration test with Flutter 3.44.0 and 3.44.4 on AGP 9 - opt-out mode, and Flutter 3.32.8, 3.35.7, and 3.41.9 on AGP 8 legacy mode. -* Verified AGP 9 built-in Kotlin mode with a release build; Flutter's current - `integration_test` Android package still blocks a full opt-in integration test. +* Tested example integration tests with: + + | Flutter | AGP | Kotlin mode | + | --- | --- | --- | + | 3.44.4 stable | 9.1.1 | Flutter AGP 9 opt-out | + | 3.44.0 | 9.1.1 | Flutter AGP 9 opt-out | + | 3.41.9 | 8.13.2 | legacy KGP | + | 3.35.7 | 8.13.2 | legacy KGP | + | 3.32.8 | 8.13.2 | legacy KGP | + * Thanks to @raph5640, @kururu-abdo, @Joschiller, and @iamnfinity for reporting the AGP 9 build problem. From 945e2aa8f664f94344907a6c657c499af21c26f4 Mon Sep 17 00:00:00 2001 From: Joachim Nohl <43643339+nohli@users.noreply.github.com> Date: Fri, 3 Jul 2026 09:23:20 +0400 Subject: [PATCH 10/10] Use correct GitHub handle --- CHANGELOG.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 58797b0..c05c793 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,8 +14,7 @@ | 3.35.7 | 8.13.2 | legacy KGP | | 3.32.8 | 8.13.2 | legacy KGP | -* Thanks to @raph5640, @kururu-abdo, @Joschiller, and @iamnfinity for reporting - the AGP 9 build problem. +* Thanks to @raph5640, @amanvishwakarma96, and @Joschiller for reporting the AGP 9 build problem. ## 0.5.1