Skip to content

Upgrade to AGP 9.2.1, Gradle 9.6.1 and Kotlin 2.3.21 - #26

Merged
recroj merged 2 commits into
mainfrom
feature/upgrade-agp-9
Jul 21, 2026
Merged

Upgrade to AGP 9.2.1, Gradle 9.6.1 and Kotlin 2.3.21#26
recroj merged 2 commits into
mainfrom
feature/upgrade-agp-9

Conversation

@recroj

@recroj recroj commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

Migrates the project from AGP 8.13.2 / Gradle 8.13 / Kotlin 1.9.21 to:

Tool Old New
Android Gradle Plugin 8.13.2 9.2.1
Gradle 8.13 9.6.1
Kotlin 1.9.21 2.3.21
KSP 1.9.21-1.0.15 2.3.9 (KSP2)
ktlint-gradle 11.5.1 14.2.0
kotlinpoet 1.15.3 2.3.0
kctfork 0.4.0 0.13.0

Build system changes

  • Built-in Kotlin (AGP 9): removed the kotlin-android plugin from demo, demolibrary and kokain-di; dropped manual KSP srcDir registrations and explicit stdlib dependencies. kotlin-allopen keeps working with built-in Kotlin.
  • New AGP DSL: minSdk/targetSdk properties, packaging {} block, proguard-android-optimize.txt (AGP 9 rejects proguard-android.txt), publishing.singleVariant('release') for kokain-di, removed versionCode/versionName from library modules; compileSdk/targetSdk 33 → 36.
  • Gradle 9: source/targetCompatibility moved into the java {} extension, removed jcenter(), cleaned obsolete gradle.properties flags (jetifier, --illegal-access).
  • ktlint 1.x: rule configuration moved to a new .editorconfig (intellij_idea code style to keep the previous rule behaviour), ktlintFormat applied.
  • JVM toolchain pinned to 17 in all six JVM modules plus gradle-daemon-jvm.properties, so builds are independent of the daemon JVM.

Code changes

  • kokain-processor/EBeanModel: kotlinpoet 2.x made toKmClass internal → read KmClass via the public kotlin-metadata-jvm API (KotlinClassMetadata.readStrict) and use the typed visibility accessor instead of the removed Flag API.
  • kokain-ksp tests: kctfork 0.13 configures processors via configureKsp {} (KSP2).
  • String.toLowerCase()lowercase() (deprecation promoted to error in Kotlin 2.x).
  • LoggerTest: Assert.assertThrows (junit 4.13.2) instead of try/catch to satisfy PMD 7.

Verification

  • ./gradlew build green: all 331 tasks incl. lint, ktlint, PMD
  • 18/18 unit tests pass (same count as before the migration), incl. the KSP2 processor compile tests
  • ./gradlew ktlintCheck jacocoTestReport (exact CI command) green
  • :demo:installDebug — demo app installed and launched on a physical device; KSP2 code generation verified (GeneratedFactory.kt, shadow classes)

Jerko Horvat added 2 commits July 9, 2026 11:01
Build system:
- AGP 8.13.2 -> 9.2.1, Gradle wrapper 8.13 -> 9.6.1,
  Kotlin 1.9.21 -> 2.3.21, KSP -> 2.3.9 (new standalone versioning,
  symbol-processing-gradle-plugin artifact)
- Migrate Android modules (demo, demolibrary, kokain-di) to built-in
  Kotlin: drop kotlin-android plugin, remove manual KSP srcDir blocks
  and explicit kotlin-stdlib dependencies
- Migrate to the new AGP DSL: minSdk/targetSdk properties, packaging{},
  proguard-android-optimize.txt, compileSdk/targetSdk 33 -> 36, drop
  versionCode/versionName from library modules, add
  publishing.singleVariant('release') to kokain-di, remove stale
  buildscript block
- Gradle 9: move source/targetCompatibility into the java{} extension,
  remove jcenter() repositories, drop obsolete jetifier and
  illegal-access properties from gradle.properties
- ktlint-gradle 11.5.1 -> 14.2.0: rule configuration moved to new
  .editorconfig (intellij_idea code style), ktlintFormat applied

Code fixes for the new toolchain:
- kotlinpoet 1.15.3 -> 2.3.0: KotlinPoetMetadataPreview/toKmClass are
  gone; read KmClass via kotlin-metadata-jvm (KotlinClassMetadata
  .readStrict) and use the typed visibility accessor instead of Flag
- kctfork 0.4.0 -> 0.13.0: configure processors via configureKsp{}
  (KSP2)
- Replace deprecated-to-error String.toLowerCase with lowercase()
- LoggerTest: use Assert.assertThrows (junit 4.13.2) to satisfy PMD 7
- FactoryGenerator: constant moved to top-level const val (ktlint
  property-naming)
Android Studio generated gradle-daemon-jvm.properties requiring a
JetBrains JDK 21 daemon. With the daemon on 21, the Kotlin JVM modules
compiled Kotlin against target 21 while Java stayed on 17, failing
KGP's jvm-target consistency check; the CLI also could not provision
the JetBrains JDK on this network.

- kotlin.jvmToolchain(17) in all six JVM modules, making compilation
  independent of the daemon JVM
- daemon JVM criteria set to plain Java 17 (matches CI and the locally
  installed JDKs; no vendor pin)
- keep the IDE-added foojay-resolver-convention plugin in
  settings.gradle so toolchains can be auto-provisioned when needed
@recroj
recroj requested review from a team, mpradzin, sbra0902 and sden1403 as code owners July 9, 2026 09:35
@recroj
recroj merged commit 2b08e6f into main Jul 21, 2026
1 check passed
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.

2 participants