Skip to content

build(android): [AGP New DSL 2] Compile Android modules with AGP's built-in Kotlin - #6654

Draft
runningcode wants to merge 2 commits into
no/agp-new-dsl-9from
no/agp-new-dsl-9-builtin-kotlin
Draft

runningcode wants to merge 2 commits into
no/agp-new-dsl-9from
no/agp-new-dsl-9-builtin-kotlin

Conversation

@runningcode

@runningcode runningcode commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

PR Stack (AGP New DSL 9.x.x)


📜 Description

Compiles the Android modules with AGP's built-in Kotlin and drops org.jetbrains.kotlin.android and android.builtInKotlin=false.

Note

The first commit is a cherry-pick of #6642 (sentry-compose → com.android.kotlin.multiplatform.library), which built-in Kotlin needs: AGP rejects kotlin.multiplatform + com.android.library once it's on. Review only the second commit. The cherry-pick merges away cleanly once #6642 syncs into 9.x.x.

  • Unit tests target Java 11. Built-in Kotlin compiles every component of a module for the single compileOptions target, so the convention's JDK 21 target for Android unit tests is gone. JVM and KMP tests still target 21.
  • sentry-test-support targets Java 11. It's unpublished and was compiled for 21, but sentry-android-core's tests inline its helpers, and Kotlin can't inline bytecode of a higher target.
  • sentry-android-ndk-outproc set its Kotlin target to JVM_1_8 against a Java 11 compile target. kotlin-android tolerated the mismatch; AGP doesn't.
  • Android ABI validation. Built-in Kotlin has no KGP abiValidation or checkKotlinAbi. AndroidAbiValidation.kt generalizes build(compose): [AGP New DSL 1] Move sentry-compose to the KMP Android library plugin #6642's KMP dump task to com.android.library: it gets the release classes through the Variant API, dumps them with org.jetbrains.kotlin:abi-tools, and hooks into checkKotlinAbi, updateKotlinAbi and check. It reproduces every existing .api file byte for byte.
  • test-app-size sets enableKotlin = false: it has no Kotlin, and the size measurement shouldn't include the stdlib.

The Kotlin module name changes from <module>_release to <module>. That renames the .kotlin_module file and the mangled names of internal members (29 in replay, 2 in navigation3). Nothing outside their own modules references them.

💡 Motivation and Context

AGP 10 removes android.builtInKotlin=false, and org.jetbrains.kotlin.android can't run with the new DSL, which blocks dropping android.newDsl=false.

💚 How did you test it?

  • check on all 13 Android modules and sentry-test-support: tests, lint, detekt and ABI.
  • The samples build, the Android sample, both UI test apps and test-app-size.
  • Compared the published artifacts with stock 9.x.x: same files, POMs, manifests, keep rules and class lists, still Java 11 bytecode. The only difference outside sentry-compose is the module name above.
  • On AGP 9.0.0, checkReleaseUnitTestAarMetadata fails in sentry-android-core and sentry-android-navigation, because test dependency androidx.core 1.19.1 needs AGP 9.1+. Stock 9.x.x fails the same way, and the AGP matrix only assembles the UI tests.

📝 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

Drop android.newDsl=false in the next stack PR.

🤖 Generated with Claude Code

⚠️ Merge this PR using a merge commit (not squash). Only the collection branch is squash-merged into 9.x.x.

#skip-changelog

runningcode and others added 2 commits November 17, 2026 16:01
KMP modules can't combine org.jetbrains.kotlin.multiplatform with
com.android.library once AGP's built-in Kotlin is on, which the new AGP
DSL needs. sentry-compose now uses com.android.kotlin.multiplatform.library.

The Kotlin Gradle plugin's ABI validation skips the new Android target,
so build-logic dumps it with the same abi-tools and hooks into
checkKotlinAbi and updateKotlinAbi. The JDK target, Robolectric and
CodeQL conventions learn the new plugin, lint needs com.android.lint,
and detekt's test excludes gain the androidHostTest source set.

The plugin has no BuildConfig, so the version comes from a generated
internal constant and io.sentry.compose.BuildConfig is gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The org.jetbrains.kotlin.android plugin can't run with the new AGP DSL,
so the Android modules drop it and android.builtInKotlin=false goes away.

Built-in Kotlin compiles every component of a module for the single
compileOptions target, so Android unit tests now target Java 11 like the
main code, and sentry-test-support, whose inline helpers they call,
compiles for Java 11 too.

KGP doesn't register ABI validation under built-in Kotlin, so the
Android ABI dump from build-logic now covers com.android.library modules
as well, reading the release classes through the Variant API. It
reproduces every existing dump.

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

linear-code Bot commented Nov 18, 2026

Copy link
Copy Markdown

JAVA-651

@sentry

sentry Bot commented Nov 18, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

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

⚙️ sentry-android Build Distribution Settings

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant