Skip to content

build: update Kotlin to 2.2.20 in purchases_ui_flutter - #1875

Closed
AlvaroBrey wants to merge 1 commit into
mainfrom
build/bump-kotlin-2.2
Closed

build: update Kotlin to 2.2.20 in purchases_ui_flutter#1875
AlvaroBrey wants to merge 1 commit into
mainfrom
build/bump-kotlin-2.2

Conversation

@AlvaroBrey

@AlvaroBrey AlvaroBrey commented Aug 26, 2026

Copy link
Copy Markdown
Member
  • Bumps ext.kotlin_version in purchases_ui_flutter/android/build.gradle from 1.9.20 to 2.2.20. One line.
  • Required before this plugin can take the next purchases-hybrid-common release (build: update Kotlin to 2.2.20 purchases-hybrid-common#1844), which publishes kotlin-stdlib with metadata 2.2.0. A Kotlin compiler reads metadata at most one minor ahead, so 1.9.20 cannot consume it.
  • purchases_flutter is deliberately untouched. Its Android sources are Java only, so its compileKotlin task has no sources and never reads that metadata. Its stale kotlin_version is harmless.
  • App developers do not need to change their Kotlin version. The plugin pins its own KGP in buildscript, it does not read the app's. They do need Gradle 7.6.3 or newer, which is KGP 2.2.20's minimum.
  • Unrelated to the Built-in Kotlin work in Prepare both Android packages for AGP 9 built-in Kotlin #1765, which is blocked upstream on Flutter. This PR touches the same lines, so expect a conflict, but the two changes are compatible in substance.

Checklist

  • A description about what and why you are contributing
  • The issue number(s) or PR number(s) in the description
  • If applicable, unit tests
Agent description

Motivation

purchases-android v11 moves to Kotlin 2.2.21, and purchases-hybrid-common follows in
RevenueCat/purchases-hybrid-common#1844. Both publish kotlin-stdlib at compile scope, so Gradle
resolves consumers onto it, and a compiler reads metadata from at most one minor version ahead of
itself. The published metadata becomes 2.2.0, which a 1.9.20 compiler rejects.

Scope

Only purchases_ui_flutter needs the bump. Checked directly:

Module Kotlin sources Java sources Needs bump
purchases_flutter/android 0 1 no
purchases_ui_flutter/android 9 0 yes

javac does not read .kotlin_module metadata, so a Java-only module is unaffected. Its
kotlin-stdlib-jdk7 dependency resolves up to the newer version at runtime, which is fine.

Consumer impact

This plugin pins its Kotlin Gradle Plugin version in its own buildscript block rather than reading
rootProject.ext, so an app's Kotlin version is irrelevant here and app developers are not forced to
change it. The one real requirement is Gradle 7.6.3 or newer, KGP 2.2.20's stated minimum.

Relationship to #1765

#1765 restructures these same lines, moving the KGP classpath and kotlinOptions behind an
applyLegacyKgp conditional for AGP 9 built-in Kotlin. That work is held on a Flutter upstream
issue (#1759) and is a different problem from this one: it is about apps that want to run AGP 9,
whereas this is about the Kotlin metadata floor. ext.kotlin_version survives #1765's
restructuring, so whichever lands second just needs a textual conflict resolved.

Testing

flutter build apk --debug on revenuecat_examples/purchase_tester builds successfully with the
bump applied, with :purchases_ui_flutter:compileDebugKotlin running under 2.2.20. Note the plugin's
android/ directory has no Gradle wrapper of its own, so it can only be built through a host app.

Related

purchases-android v11, and the purchases-hybrid-common release that
carries it, publish kotlin-stdlib with metadata 2.2.0. A Kotlin compiler
reads metadata at most one minor ahead, so the 1.9.20 pinned here cannot
consume it. 2.2.21 is the latest 2.2.x and matches the other repos.

Only purchases_ui_flutter needs this. The purchases_flutter Android
sources are Java-only, so its compileKotlin task has no sources and never
reads that metadata; its own kotlin_version is left alone.

The plugin pins its own KGP rather than reading it from the app, so app
developers are not forced to change their Kotlin version. They do need
Gradle 7.6.3 or newer, which is KGP 2.2.21's minimum.
@AlvaroBrey
AlvaroBrey force-pushed the build/bump-kotlin-2.2 branch from 165d1ae to fd83630 Compare August 27, 2026 07:15
@AlvaroBrey

AlvaroBrey commented Aug 27, 2026

Copy link
Copy Markdown
Member Author

Closing: this change is a no-op.

Verified against a purchases-hybrid-common built with Kotlin 2.2.21 and published locally under a unique version, so resolution was provable:

  • app declares Kotlin 1.8.22, plugin at 2.2.21 -> FAILS (:purchases_ui_flutter:compileDebugKotlin, metadata 2.2.0 unreadable)
  • app declares Kotlin 2.1.21, plugin left at its original 1.9.20 -> BUILDS

So ext.kotlin_version in purchases_ui_flutter/android/build.gradle does not control the compiler in an app context. Flutter's plugin loader applies org.jetbrains.kotlin.android from the app's own settings.gradle to plugin subprojects, and that is what decides it.

The real requirement is on the app side: a Flutter app consuming the next PHC release needs Kotlin 2.1.0 or newer in its android/settings.gradle. That is a release-notes and migration-guide item, not a code change here. Flutter's own app template already ships 2.3.20, so only older apps are affected, and they can bump Kotlin without changing their Flutter version.

@AlvaroBrey AlvaroBrey closed this Aug 27, 2026
@AlvaroBrey
AlvaroBrey deleted the build/bump-kotlin-2.2 branch August 27, 2026 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:breaking Changes that are breaking pr:other

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant