Migrate Android build to Kotlin DSL and Built-in Kotlin (AGP 9.0.1)#456
Open
faheem-riaz wants to merge 4 commits into
Open
Migrate Android build to Kotlin DSL and Built-in Kotlin (AGP 9.0.1)#456faheem-riaz wants to merge 4 commits into
faheem-riaz wants to merge 4 commits into
Conversation
|
Reviews (1): Last reviewed commit: "Fix deprecated srcDirs and outputs.upToD..." | Re-trigger Greptile |
marandaneto
reviewed
Jun 29, 2026
Comment on lines
-29
to
-41
| def agpMajor = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')[0] as int | ||
| if (agpMajor < 9) { | ||
| apply plugin: 'kotlin-android' | ||
| } else { | ||
| // AGP 9 enables built-in Kotlin by default. Flutter templates can explicitly opt out | ||
| // with android.builtInKotlin=false, in which case we still apply kotlin-android. | ||
| def builtInKotlin = providers.gradleProperty('android.builtInKotlin') | ||
| .map { it.toBoolean() } | ||
| .getOrElse(true) | ||
| if (!builtInKotlin) { | ||
| apply plugin: 'kotlin-android' | ||
| } | ||
| } |
marandaneto
reviewed
Jun 29, 2026
Comment on lines
+10
to
+11
| classpath("com.android.tools.build:gradle:9.0.1") | ||
| // KGP not needed: AGP 9 provides Built-in Kotlin support by default. |
Member
There was a problem hiding this comment.
we cannot do this, see this https://github.com/PostHog/posthog-flutter/pull/456/changes#r3491732397
otherwise this plugin wont work with older flutter versions
marandaneto
reviewed
Jun 29, 2026
Comment on lines
+31
to
+32
| sourceCompatibility = JavaVersion.VERSION_17 | ||
| targetCompatibility = JavaVersion.VERSION_17 |
Member
There was a problem hiding this comment.
same, we should keep 1.8 to be compatible with older versions
marandaneto
reviewed
Jun 29, 2026
| @@ -0,0 +1,66 @@ | |||
| group = "com.posthog.flutter" | |||
| version = "1.0-SNAPSHOT" | |||
|
|
|||
Member
There was a problem hiding this comment.
missing jvmTarget in this file
marandaneto
reviewed
Jun 29, 2026
|
|
||
| android { | ||
| namespace = "com.posthog.flutter" | ||
| compileSdk = 35 |
Member
There was a problem hiding this comment.
we should read from flutter.compileSdkVersion
… compatibility with older Flutter versions
Author
|
Hi @marandaneto, thank you for the review! I have addressed all your feedback:
Please let me know if there's anything else! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR migrates the Android build configuration for
posthog_flutterfrom Groovy DSL (build.gradle) to Kotlin DSL (build.gradle.kts), and upgrades the Android Gradle Plugin (AGP) classpath to version 9.0.1.Background
Flutter's official migration guide — Migrate to Built-in Kotlin — requires plugin authors to stop applying the Kotlin Gradle Plugin (KGP) explicitly. Starting with AGP 9, Kotlin support is built into the Android Gradle Plugin by default, making the separate
kotlin-gradle-pluginclasspath dependency redundant. Continuing to declare it will cause build warnings today and is expected to cause build failures in future Flutter releases.Changes
posthog_flutter/android/build.gradleposthog_flutter/android/build.gradle.ktsKey Migration Details
.ktssyntax, including block-level API calls (plugins {},android {},dependencies {}).org.jetbrains.kotlin:kotlin-gradle-pluginclasspath entry has been removed. AGP 9 manages Kotlin compilation natively via Built-in Kotlin.com.android.tools.build:gradleclasspath has been updated from8.11.1to9.0.1.Testing
The updated build configuration has been verified to compile successfully against Flutter 3.44.4 with Gradle 9.5.1.