Skip to content

build: Bump Kotlin to 2.4.21 and the language/API version to 2.0 - #6487

Closed
runningcode wants to merge 3 commits into
9.x.xfrom
no/bump-kotlin-2.4
Closed

runningcode wants to merge 3 commits into
9.x.xfrom
no/bump-kotlin-2.4

Conversation

@runningcode

@runningcode runningcode commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

📜 Description

Bumps Kotlin to 2.4.21 and raises the Kotlin language and API version of the published modules from 1.9 to 2.0. Those modules now depend on kotlin-stdlib 2.0.21 instead of 1.9.24.

Kotlin applications that use the SDK need Kotlin 1.9 or newer, up from 1.8. A Kotlin compiler reads metadata one minor version ahead, so a 1.9 compiler can read our 2.0 classes. Java-only applications aren't affected.

Other changes the bump needed:

  • Kotlin module names: KGP 2.4 prefixes the module name with the group, e.g. io.sentry:sentry-android-fragment_release. R8 writes that colon into the names of the .kotlin_module files it outputs, and app bundles reject it (Entry name contains invalid characters). JdkTargetConvention now pins the module name to the project name, so the module files keep the names 8.x shipped.
  • SentryApiValidationPlugin: KGP 2.4 removed the experimental ABI validation API this plugin used (enabled, AbiValidationMultiplatformExtension). Validation is now enabled by calling abiValidation { }, which works the same for JVM, Android and multiplatform modules.
  • ABI dumps:
    • sentry-android-fragment: FragmentLifecycleState gains getEntries(), because at language 2.0 the compiler generates entries for Kotlin enums. This is an addition.
    • sentry-android-sqlite, sentry-android-navigation3: the KGP 2.4 dumper no longer lists public synthetic constructors. The bytecode is unchanged; I compared it with 8.63.0.
  • test-app-size: Compose's $stable fields now reference kotlin.jvm.JvmField. This app leaves out the Kotlin stdlib on purpose, so it gets one more -dontwarn.
  • sentry-compose tests: at language 2.0 the compiler uses its new K2 frontend. With @Suppress("INVISIBLE_REFERENCE"), K2 compiles locals whose inferred type is an internal Compose class (LayoutNode, Owner) to error.NonExistentClass, and the tests failed with NoClassDefFoundError. Those locals are now typed explicitly.

K2 also warns that suppressing INVISIBLE_REFERENCE has unspecified behavior. Session Replay's masking code (SentryLayoutNodeHelper, Nodes, ComposeViewHierarchyNode) and three sentry-compose classes rely on it. Their compiled classes contain no error.NonExistentClass and their unit tests pass, but the UI tests are the real check for them.

SentryLog4j2AppenderAutoConfigurationTest in sentry-spring-boot-jakarta is flaky, and also fails on 9.x.x without this change.

💡 Motivation and Context

Kotlin 2.4 rejects language and API version 1.9, so keeping the 1.9 floor meant staying on Kotlin 2.3. 2.0 is the oldest version Kotlin 2.4 accepts. It's deprecated there, so the build prints a warning. This ships in SDK 9 together with its other new minimum requirements.

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.

🔮 Next steps

🤖 Generated with Claude Code

runningcode and others added 3 commits November 6, 2026 09:38
Kotlin 2.4 rejects language and API version 1.9, so the Kotlin modules
now target 2.0 and depend on kotlin-stdlib 2.0.21. Kotlin applications
need Kotlin 1.9 or newer, up from 1.8.

KGP 2.4 replaced the experimental ABI validation DSL, so enable it
through abiValidation {}. Its dumper no longer lists synthetic
constructors, which drops three lines from the sqlite and navigation3
dumps. Compiling at 2.0 uses K2, which adds getEntries() to Kotlin
enums, references kotlin.jvm.JvmField from Compose $stable fields, and
compiles locals of suppressed internal Compose types to
error.NonExistentClass, so type those test locals explicitly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
KGP 2.4 prefixes the Kotlin module name with the group, e.g.
io.sentry:sentry-android-fragment_release. The compiler writes the
.kotlin_module file with an underscore instead of the colon, but R8
writes the entry again from the module name, colon included, and app
bundles reject it. That broke bundleRelease of the size test app.

Pin the module name to the project name, which restores the module file
names 8.x shipped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sentry

sentry Bot commented Nov 6, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.63.0 (1) release

⚙️ sentry-android Build Distribution Settings

@runningcode runningcode closed this Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant