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

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 and purchases to 11-snapshot 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
AlvaroBrey added a commit to RevenueCat/purchases-hybrid-common that referenced this pull request Sep 23, 2026
> Targets the next major branch (20.0-dev)

- Bumps Kotlin from 2.0.21 to 2.2.20.
- Bumps `purchases-android` to `11.0.0-SNAPSHOT` which is published from
the `11.0-dev` branch.
- **Required by the purchases-android v11 major**
(RevenueCat/purchases-android#3964). v11 publishes `kotlin-stdlib` with
metadata 2.2.0, and a Kotlin compiler reads metadata at most one minor
ahead, so our 2.0.21 compiler cannot consume it.
- **Raises the Kotlin floor for anything that compiles Kotlin against
PHC to 2.1**, because we publish `kotlin-stdlib` at compile scope too.
This is not extra breakage: `api(libs.purchases)` re-exposes purchases
at compile scope, so the v11 bump forces the same floor regardless of
what PHC itself compiles with.
- `kotlinLanguage` deliberately stays at `1.8`. Kotlin 2.2.20 still
accepts it, so this is a compiler bump and not a K1 to K2 migration.

Companion PRs: RevenueCat/purchases-flutter#1876
RevenueCat/react-native-purchases#1925

### Checklist
- [x] A description about what and why you are contributing
- [x] The issue number(s) or PR number(s) in the description
- [ ] If applicable, unit tests

<details><summary>Agent description</summary>

### Motivation

purchases-android v11 moves to Kotlin 2.2.21 as part of its AGP 9
upgrade. The Kotlin Gradle Plugin
publishes `kotlin-stdlib` at `compile` scope, so Gradle resolves
consumers onto it, and a compiler
can only read metadata from at most one minor version ahead of itself.
v11's stdlib carries metadata
2.2.0, which a 2.0.21 compiler rejects with:

```
Module was compiled with an incompatible version of Kotlin.
The binary version of its metadata is 2.2.0, expected version is 2.0.0.
```

So PHC has to move to at least 2.1 before it can take v11. 2.2.20 is
chosen to match what
purchases-capacitor already pins, so the hybrids converge on one
version.

### Why this is separable from the purchases bump

PHC compiles cleanly on Kotlin 2.2.20 with `purchases` still at 10.18.1,
verified locally. That makes
this landable before the v11 release rather than gated behind it, which
is the whole reason it is its
own PR.

### Downstream impact

Consumers that compile Kotlin against PHC need a compiler of 2.1 or
newer after this:

| Consumer | Compiler | Status |
|---|---|---|
| purchases-flutter `purchases_ui_flutter` | KGP 1.9.20 | needs
RevenueCat/purchases-flutter#1875 |
| react-native apps on RN 0.78 / 0.79 | KGP 2.0.21 | needs
RevenueCat/react-native-purchases#1925 |
| react-native apps on RN 0.81+ | KGP 2.1.20 | fine, reads 2.2.0 |
| purchases-capacitor | 2.2.20 | fine |
| cordova, unity | Java only, no Kotlin compilation | fine |

**Merging this is safe. Releasing it is what needs sequencing.** Once a
PHC version ships with this,
the automated PHC bump PRs open against purchases-flutter and
react-native-purchases and will fail
their CI until their Kotlin prep lands. Land #1875 and #1925 first, or
hold the PHC release for the
coordinated major.

### Testing

`cd android && ./gradlew assembleRelease` passes on 2.2.20 with
`purchases` unchanged at 10.18.1.
Only pre-existing deprecation warnings, plus the expected `Language
version 1.8 is deprecated` note.
The generated POM confirms the new contract: `kotlin-stdlib:2.2.20` at
`compile` scope.

### Related

- RevenueCat/purchases-android#3964 introduces the floor this responds
to
- RevenueCat/purchases-flutter#1875 and
RevenueCat/react-native-purchases#1925 are the downstream
  Kotlin bumps that must land before a PHC release carrying this

</details>


<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Major dependency and Kotlin compiler bumps affect all Android modules
and raise the minimum Kotlin version for consumers once released;
snapshot repo adds transient resolution risk until v11 is stable.
> 
> **Overview**
> **Aligns the Android hybrid-common build with purchases-android v11**
by bumping the Kotlin toolchain and core SDK dependency, plus raising
the compile SDK across modules.
> 
> The version catalog moves **Kotlin from 2.0.21 to 2.2.21** and
**`purchases-android` from 10.22.1 to `11.0.0-SNAPSHOT`** (with a note
to pin stable `11.0.0` later). **`compileSdk` is raised from 34 to 36**
in `api-tests`, `hybridcommon`, `hybridcommon-ui`, and
`hybridcommon-store-galaxy`.
> 
> **Gradle resolution** adds a temporary **Sonatype Maven Snapshots**
repository scoped to `com.revenuecat.purchases` so the v11 snapshot
resolves until it ships to Maven Central.
> 
> This is primarily a **compiler and dependency floor** change (Kotlin
metadata from v11 requires a newer compiler); `kotlinLanguage` stays at
1.8 per the PR intent.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
a6c1eb3. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
AlvaroBrey added a commit to RevenueCat/purchases-hybrid-common that referenced this pull request Sep 24, 2026
> Targets the next major branch (20.0-dev)

- Bumps Kotlin from 2.0.21 to 2.2.20.
- Bumps `purchases-android` to `11.0.0-SNAPSHOT` which is published from
the `11.0-dev` branch.
- **Required by the purchases-android v11 major**
(RevenueCat/purchases-android#3964). v11 publishes `kotlin-stdlib` with
metadata 2.2.0, and a Kotlin compiler reads metadata at most one minor
ahead, so our 2.0.21 compiler cannot consume it.
- **Raises the Kotlin floor for anything that compiles Kotlin against
PHC to 2.1**, because we publish `kotlin-stdlib` at compile scope too.
This is not extra breakage: `api(libs.purchases)` re-exposes purchases
at compile scope, so the v11 bump forces the same floor regardless of
what PHC itself compiles with.
- `kotlinLanguage` deliberately stays at `1.8`. Kotlin 2.2.20 still
accepts it, so this is a compiler bump and not a K1 to K2 migration.

Companion PRs: RevenueCat/purchases-flutter#1876
RevenueCat/react-native-purchases#1925

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

<details><summary>Agent description</summary>

purchases-android v11 moves to Kotlin 2.2.21 as part of its AGP 9
upgrade. The Kotlin Gradle Plugin
publishes `kotlin-stdlib` at `compile` scope, so Gradle resolves
consumers onto it, and a compiler
can only read metadata from at most one minor version ahead of itself.
v11's stdlib carries metadata
2.2.0, which a 2.0.21 compiler rejects with:

```
Module was compiled with an incompatible version of Kotlin.
The binary version of its metadata is 2.2.0, expected version is 2.0.0.
```

So PHC has to move to at least 2.1 before it can take v11. 2.2.20 is
chosen to match what
purchases-capacitor already pins, so the hybrids converge on one
version.

PHC compiles cleanly on Kotlin 2.2.20 with `purchases` still at 10.18.1,
verified locally. That makes
this landable before the v11 release rather than gated behind it, which
is the whole reason it is its
own PR.

Consumers that compile Kotlin against PHC need a compiler of 2.1 or
newer after this:

| Consumer | Compiler | Status |
|---|---|---|
| purchases-flutter `purchases_ui_flutter` | KGP 1.9.20 | needs
RevenueCat/purchases-flutter#1875 |
| react-native apps on RN 0.78 / 0.79 | KGP 2.0.21 | needs
RevenueCat/react-native-purchases#1925 |
| react-native apps on RN 0.81+ | KGP 2.1.20 | fine, reads 2.2.0 |
| purchases-capacitor | 2.2.20 | fine |
| cordova, unity | Java only, no Kotlin compilation | fine |

**Merging this is safe. Releasing it is what needs sequencing.** Once a
PHC version ships with this,
the automated PHC bump PRs open against purchases-flutter and
react-native-purchases and will fail
their CI until their Kotlin prep lands. Land #1875 and #1925 first, or
hold the PHC release for the
coordinated major.

`cd android && ./gradlew assembleRelease` passes on 2.2.20 with
`purchases` unchanged at 10.18.1.
Only pre-existing deprecation warnings, plus the expected `Language
version 1.8 is deprecated` note.
The generated POM confirms the new contract: `kotlin-stdlib:2.2.20` at
`compile` scope.

- RevenueCat/purchases-android#3964 introduces the floor this responds
to
- RevenueCat/purchases-flutter#1875 and
RevenueCat/react-native-purchases#1925 are the downstream
  Kotlin bumps that must land before a PHC release carrying this

</details>

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Major dependency and Kotlin compiler bumps affect all Android modules
and raise the minimum Kotlin version for consumers once released;
snapshot repo adds transient resolution risk until v11 is stable.
>
> **Overview**
> **Aligns the Android hybrid-common build with purchases-android v11**
by bumping the Kotlin toolchain and core SDK dependency, plus raising
the compile SDK across modules.
>
> The version catalog moves **Kotlin from 2.0.21 to 2.2.21** and
**`purchases-android` from 10.22.1 to `11.0.0-SNAPSHOT`** (with a note
to pin stable `11.0.0` later). **`compileSdk` is raised from 34 to 36**
in `api-tests`, `hybridcommon`, `hybridcommon-ui`, and
`hybridcommon-store-galaxy`.
>
> **Gradle resolution** adds a temporary **Sonatype Maven Snapshots**
repository scoped to `com.revenuecat.purchases` so the v11 snapshot
resolves until it ships to Maven Central.
>
> This is primarily a **compiler and dependency floor** change (Kotlin
metadata from v11 requires a newer compiler); `kotlinLanguage` stays at
1.8 per the PR intent.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
a6c1eb3. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
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