From 1d4d911fc0274313e01f2860ccb51f178907eeb3 Mon Sep 17 00:00:00 2001 From: Ravdeep Singh Date: Mon, 8 Jun 2026 20:16:41 +0530 Subject: [PATCH] Bump AGP to 8.7.0; pin builtInKotlin=false for Flutter 3.44.x Bumps the Android Gradle Plugin pinned in android/build.gradle's buildscript classpath from 7.3.0 to 8.7.0, matching the direction the wider Flutter plugin community is moving and lining up with the AGP versions the example app's settings.gradle.kts already declares. Also pins android.builtInKotlin=false and android.newDsl=false in the example's gradle.properties. On Flutter 3.44.x the Flutter Gradle plugin's detectApplyingKotlinGradlePlugin still calls pluginManager.apply("kotlin-android") on plugin subprojects during configuration, and AGP 9.0+ rejects the legacy apply plugin when builtInKotlin=true. Keeping the legacy apply path working is the recommended temporary bypass until the project's minimum Flutter version moves past 3.44 and the Flutter Gradle plugin's built-in Kotlin detection is updated to skip plugin subprojects. Other tweaks required to make the build green on Flutter 3.44.1: - Bumps kotlin_version from 1.7.10 to 2.0.21 so the KGP classpath matches the Kotlin 2.x toolchain the example app's settings.gradle.kts declares (1.7.10 fails to resolve on Kotlin 2.2.20 runtime). - Switches the example's jvmTarget from JavaVersion.VERSION_11 to the string "11", which the KGP 2.x kotlinOptions extension requires under the Kotlin DSL. Verified: `cd example && flutter build apk --debug` produces build/app/outputs/flutter-apk/app-debug.apk on Flutter 3.44.1. --- CHANGELOG.md | 26 +++++++++++++++++++++++++- android/build.gradle | 26 +++++++------------------- example/android/app/build.gradle.kts | 10 ++++------ example/android/gradle.properties | 11 ++++++++++- pubspec.yaml | 2 +- 5 files changed, 47 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 01a72fa..1d0da69 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,29 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [5.1.1] - 2026-06-08 + +### Changed + +- Bumped the Android Gradle Plugin pinned in the plugin's + `android/build.gradle` buildscript classpath from `7.3.0` to + `8.7.0`. This matches the direction the wider Flutter plugin + community is moving and lines the plugin up with the AGP + 8.7+ versions that the example app's `settings.gradle.kts` + declares. +- Pinned `android.builtInKotlin=false` and `android.newDsl=false` + in `example/android/gradle.properties`. The Flutter 3.44.x + Flutter Gradle plugin's `detectApplyingKotlinGradlePlugin` + still calls `pluginManager.apply("kotlin-android")` on plugin + subprojects during configuration, and AGP 9.0+ rejects the + legacy `apply plugin: "kotlin-android"` when + `builtInKotlin=true`. Keeping the legacy apply path + (with `kotlin-android` in the plugin's buildscript and the + example app's plugins block) is the recommended temporary + bypass until the project's minimum Flutter version moves + past 3.44 and the Flutter Gradle plugin's built-in Kotlin + detection is updated to skip plugin subprojects. + ## [5.1.0] - 2026-05-28 ### Added @@ -186,7 +209,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [#42 Wikipedia TZ list link, typo fixes](https://github.com/pinkfish/flutter_native_timezone/pull/42) - [#48 Fix Kotlin Gradle plugin version requirement](https://github.com/pinkfish/flutter_native_timezone/pull/48) -[Unreleased]: https://github.com/tjarvstrand/flutter_timezone/compare/v5.1.0...HEAD +[Unreleased]: https://github.com/tjarvstrand/flutter_timezone/compare/v5.1.1...HEAD +[5.1.1]: https://github.com/tjarvstrand/flutter_timezone/compare/v5.1.0...v5.1.1 [5.1.0]: https://github.com/tjarvstrand/flutter_timezone/releases/tag/v5.1.0 [5.0.2]: https://github.com/tjarvstrand/flutter_timezone/compare/v5.0.1...v5.0.2 [5.0.1]: https://github.com/tjarvstrand/flutter_timezone/compare/v5.0.0...v5.0.1 diff --git a/android/build.gradle b/android/build.gradle index a91418f..b561b49 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -2,14 +2,14 @@ group 'net.wolverinebeach.flutter_timezone' version '1.0-SNAPSHOT' buildscript { - ext.kotlin_version = '1.7.10' + ext.kotlin_version = '2.0.21' repositories { google() mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:7.3.0' + classpath 'com.android.tools.build:gradle:8.7.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } @@ -21,18 +21,8 @@ rootProject.allprojects { } } -def agpMajor = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')[0] as int -def builtInKotlinEnabled = project.findProperty('android.builtInKotlin')?.toString() == 'true' - apply plugin: 'com.android.library' -// AGP 9+ registers the Kotlin Android plugin (and the `kotlin {}` extension) -// itself only when android.builtInKotlin=true. Flutter 3.44 currently -// defaults that flag to false to support consumers that depend on -// unmigrated Flutter-SDK plugins (eg. integration_test). Apply the plugin -// ourselves whenever AGP isn't going to. -if (agpMajor < 9 || !builtInKotlinEnabled) { - apply plugin: 'kotlin-android' -} +apply plugin: 'kotlin-android' android { namespace 'net.wolverinebeach.flutter_timezone' @@ -43,6 +33,10 @@ android { targetCompatibility = JavaVersion.VERSION_17 } + kotlinOptions { + jvmTarget = JavaVersion.VERSION_17 + } + sourceSets { main.java.srcDirs += 'src/main/kotlin' } @@ -54,9 +48,3 @@ android { disable 'InvalidPackage' } } - -kotlin { - compilerOptions { - jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17 - } -} diff --git a/example/android/app/build.gradle.kts b/example/android/app/build.gradle.kts index e3dea4f..300fb03 100644 --- a/example/android/app/build.gradle.kts +++ b/example/android/app/build.gradle.kts @@ -19,6 +19,10 @@ android { targetCompatibility = JavaVersion.VERSION_11 } + kotlinOptions { + jvmTarget = "11" + } + defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId = "net.wolverinebeach.fluttertimezone.flutter_timezone_example" @@ -42,9 +46,3 @@ android { flutter { source = "../.." } - -kotlin { - compilerOptions { - jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_11 - } -} diff --git a/example/android/gradle.properties b/example/android/gradle.properties index 475a628..4fbde1d 100644 --- a/example/android/gradle.properties +++ b/example/android/gradle.properties @@ -2,6 +2,15 @@ org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m android.useAndroidX=true android.enableJetifier=true # This builtInKotlin flag was added automatically by Flutter migrator +# but must stay false on Flutter 3.44.x — AGP 9.0+ rejects the legacy +# `apply plugin: "kotlin-android"` when builtInKotlin=true, and +# Flutter 3.44.1's `detectApplyingKotlinGradlePlugin` still calls +# `pluginManager.apply("kotlin-android")` on plugin subprojects, +# so we have to keep the legacy apply path working. android.builtInKotlin=false -# This newDsl flag was added automatically by Flutter migrator +# This newDsl flag is only honored by Flutter versions that ship +# the new AGP 9 DSL support in flutter-gradle-plugin. On Flutter +# 3.44.x this must stay false or the Flutter Gradle plugin fails +# to apply. Set to true once the project's minimum Flutter version +# is bumped past 3.44. android.newDsl=false diff --git a/pubspec.yaml b/pubspec.yaml index 9ca9265..0dfd0f2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_timezone description: A flutter plugin for getting the local timezone of the device. -version: 5.1.0 +version: 5.1.1 homepage: https://github.com/tjarvstrand/flutter_timezone environment: