Repository navigation
build: Bump Kotlin to 2.4.21 and the language/API version to 2.1 - #6646
Draft
runningcode wants to merge 5 commits into
Draft
runningcode wants to merge 5 commits into
runningcode wants to merge 5 commits into
Conversation
Kotlin 2.4 rejects language and API version 1.9, and AGP 9.6 pulls in
KGP 2.4.20, so 1.9 can no longer be built. The Kotlin modules now target
2.1 and depend on kotlin-stdlib 2.1.21. Apps that compile Kotlin need
Kotlin 2.0 or newer, up from 1.8, the same minimum as stable AndroidX
and Firebase. Kotlin 2.4 deprecates 2.1, so the version warning is
suppressed.
KGP 2.4 prefixes Kotlin module names with the group, and R8 copies the
colon into .kotlin_module entry names, which app bundles reject, so
module names stay the project name. KGP 2.4 also replaced the
experimental ABI validation DSL, so enable it through abiValidation {}.
Its dumper no longer lists synthetic constructors, which drops lines
from the sqlite and navigation3 dumps.
Compiling at 2.1 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 those test locals are typed explicitly.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
📲 Install BuildsAndroid
|
The 9.0.0 warning block now names Kotlin next to Java and Android, and links the Kotlin bullet to the tracking issue like the other two bullets. Refs #6473 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…vention The io.sentry.jdk-target convention now sets language/API version 2.1 for the main Kotlin compilations of every published module. That replaces the settings spread over about 40 build files and the unused kotlin-compatible-version catalog entry. Test code isn't published, so it keeps the compiler's default. That moves the Android and multiplatform unit tests from 2.1 to 2.4, where BackStackConverterTest needs an explicit array type to pass the newer reified intersection type check. Samples and sentry-test-support aren't published either, so they use the default too. sentry-compose's coreLibrariesVersion is removed. With kotlin.stdlib.default.dependency=false it never reached the published metadata. Refs #6473 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Only the modules that declare kotlin-stdlib pin 2.1.21. The others use the app's own stdlib. Refs #6473 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
📜 Description
Raises the Kotlin language/API version of every published module from 1.9 to 2.1, and compiles with Kotlin 2.4.21.
Breaking for 9.0: apps that compile Kotlin need Kotlin 2.0 or newer, up from 1.8. Apps written only in Java are not affected. This is the same minimum that stable AndroidX and Firebase already require.
io.sentry.jdk-targetconvention now sets 2.1 for the main Kotlin compilations of the published modules. That replaces theKOTLIN_1_9settings that were spread over about 40 build files, and the unusedkotlin-compatible-versioncatalog entry.sentry-spring-7was already on 2.1.sentry-test-supportaren't published, so they keep the compiler's default (2.4). For the Android unit tests that's up from 2.1, so navigation3'sBackStackConverterTestnow needs an explicitarrayOf<Any>to pass a newer check on reified intersection types.kotlin-stdlib-jdk8(replay, sqlite, timber, distribution, okhttp, ktor-client) pin it at 2.1.21, up from 1.9.24. The other Kotlin modules (compose, fragment, navigation, navigation3, apollo, kotlin-extensions) declare no stdlib and use the app's own. That's safe on a Kotlin 2.0 app's stdlib: none of our classes reference stdlib API newer than 1.9.24.coreLibrariesVersionis removed. Withkotlin.stdlib.default.dependency=falseit never reached the published metadata.-jdk8artifact on purpose. At 2.1.21 it's an empty artifact that depends onkotlin-stdlib. It also pulls up any olderstdlib-jdk8coming from other libraries, so Java-only apps (which don't get the Kotlin Gradle plugin's version alignment) don't end up with duplicate classes.io.sentry.jdk-targetconvention adds-Xsuppress-version-warningsto every Kotlin compilation..kotlin_modulefile names, which app bundles reject.abiValidation {}DSL.getEntries()is added on the fragment enum, and the dumper no longer lists synthetic constructors (sqlite, navigation3).-dontwarnforkotlin.jvm.JvmField.LayoutNode/Ownerlocals explicitly. Without that, K2 compiles them toerror.NonExistentClass. This also covers a test that was added after build: Bump Kotlin to 2.4.21 and the language/API version to 2.0 #6487.The published classes now carry metadata version
2.1.0.Issues
💡 Motivation and Context
android.builtInKotlin=falseopt-out.Replaces #6487, which targeted 2.0.
💚 How did you test it?
make format api, thenassemble,compileTestKotlin,compileReleaseUnitTestKotlinandcompileTestKotlinDesktopacross the build.mv=[2,1,0]in published classes.@Suppress("INVISIBLE_REFERENCE")access under K2:./scripts/test-ui-critical.sh: 3/3 Maestro flows pass.sentry-uitest-android: 35/35 pass, includingReplayTest,ReplaySnapshotTestand the Compose click and swipe tests.kotlin.Metadata(for example for kotlin-reflect), R8 in AGP 8.0–8.5 prints about 400 warnings:An error occurred when parsing kotlin metadata. This normally happens when using a newer version of kotlin than the kotlin version released when this version of R8 was created.That happens because it can't read the 2.1 metadata. The build still succeeds, and AGP 8.6 prints none. This belongs in the 9.0 migration guide.📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
com.android.kotlin.multiplatform.library.🤖 Generated with Claude Code