Skip to content

build(deps): forward port to android gradle plugin 9#19423

Merged
mikehardy merged 1 commit into
ankidroid:mainfrom
mikehardy:agp9
Apr 16, 2026
Merged

build(deps): forward port to android gradle plugin 9#19423
mikehardy merged 1 commit into
ankidroid:mainfrom
mikehardy:agp9

Conversation

@mikehardy
Copy link
Copy Markdown
Member

@mikehardy mikehardy commented Nov 4, 2025

AGP9 changes all sorts of stuff, but it's mostly easy

The only thing truly difficult (IMNSHO) is that someone (could be us...) needs to provide a stable forever home for the "Keeper" plugin which allows us to test minified builds - it has an AGP9 forward-port PR but that will likely never be published in current repo - until we solve or workaround that (with a local maven repo and vendored build?) we cannot enable newDsl, currently we have to disable it for compatibility reasons with that plugin

@mikehardy mikehardy marked this pull request as draft November 4, 2025 18:55
@mikehardy mikehardy changed the base branch from main to dependency-updates November 4, 2025 18:55
@mikehardy mikehardy force-pushed the dependency-updates branch 2 times, most recently from 0aaf9b6 to 7f74098 Compare November 14, 2025 11:05
@mikehardy mikehardy force-pushed the dependency-updates branch 3 times, most recently from 51d2c22 to 9a164ee Compare December 6, 2025 05:21
@mikehardy mikehardy force-pushed the dependency-updates branch 3 times, most recently from 6d8f967 to c2e0e7d Compare December 29, 2025 12:22
@mikehardy
Copy link
Copy Markdown
Member Author

getting closer here, AGP9 is at rc02 now and likely to release soon --> https://mvnrepository.com/artifact/com.android.application/com.android.application.gradle.plugin

kotlin 2.3.0 (a transitive dep for it) is already out

I haven't looked to see which of my workarounds etc are still needed, but this is updated now

@mikehardy
Copy link
Copy Markdown
Member Author

@david-allison this is a mix of "ready for review" in that I believe I have the commits all cleaned up and the fixes themselves are clean, and "blocked by dependency" because as far as I know we need kotlin 2.3.0 for AGP9, and we are blocking that pending the codeql fix since it appears to be scheduled to land in just a few weeks

we could decide to let codeql fail for a while and merge kotlin 2.3.0, or we could continue to wait - it's a choice we make. I'm currently fine waiting for what it's worth, AGP9 and kotlin 2.3.0 don't add anything that we are really waiting for do they? And we're ready when codeql works. But if I'm wrong (maybe kotlin 2.3.0 adds something?) or if the codeql schedule slips, I'll change my mind to "land it now, accept the codeql break for a while"

@mikehardy mikehardy changed the title Experimental android gradle plugin 9 fork / PR build(deps): forward port to android gradle plugin 9 Jan 17, 2026
@mikehardy mikehardy force-pushed the agp9 branch 2 times, most recently from fd770c2 to 7d119ba Compare January 17, 2026 23:31
Copy link
Copy Markdown
Member

@david-allison david-allison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still LGTM. Leaving it to you, as there will be squashes

@mikehardy
Copy link
Copy Markdown
Member Author

mikehardy commented Apr 15, 2026

Assuming CI works (it's unsquashed for now until it's CI-clean):

  • pull dependency-updates locally and I believe it's still up to date with main, if reasonably so squash it locally for the commit message and push that
  • wait for CI on that one because it's really chunky, then rebase-merge the clean squash commit on to main
  • squash this one locally (so commit message is the squash-compilation - web UI still not doing that for me ?) and re-push - not wait for CI though as it'll be a pure squash
  • rebase merge this onto main
  • ???
  • profit

Slightly re-ordered since dependency-updates went in first

@mikehardy mikehardy added Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) squash-merge A squash & force push is required. The PR author may do this to speed up the merge process. and removed Needs Author Reply Waiting for a reply from the original author labels Apr 15, 2026
@mikehardy
Copy link
Copy Markdown
Member Author

gah, now on android test working but not generating coverage, was afraid of that - hopefully easy
process once fixed will be in the comment above regardless (for my reference, in future)

@mikehardy mikehardy added Needs Author Reply Waiting for a reply from the original author and removed Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) labels Apr 15, 2026
@mikehardy
Copy link
Copy Markdown
Member Author

The AGP9 migration is ready to go with the only remaining bit being that ./gradlew clean && ./gradlew jacocoAndroidTestReport generates an empty coverage report (noted by our gradle task finalizer assertNonzeroAndroidTestCoverage which is checking for a non-zero count of nodes in the file reports/jacoco/jacocoAndroidTestReport/jacocoAndroidTestReport.xml that are anything but 'coverage="0"')

I have a hunch that it is because in the AnkiDroid/jacoco.gradle file the classes directories have moved now that Android Gradle Plugin 9 has "built in Kotlin", and based on that hunch I investigated and saw that indeed the classes directories are now of the format:

./build/intermediates/built_in_kotlinc/playDebug/compilePlayDebugKotlin/classes/com/ichi2/anki/CardBrowser.class
./build/intermediates/built_in_kotlinc/playRelease/compilePlayReleaseKotlin/classes/com/ichi2/anki/CardBrowser.class

...for example - and I believe we need to point jacoco report task to that 'built_in_kotlinc/play/compileKotlin/classes' directory but I was unsuccessful when I attempted it

I saw some information online that indicated I may be able to get a handle on the Compile task and ask it for destinationDir property to dynamically fetch where to point jacoco but was also unsuccessful

At this point I'm stumped.

@mikehardy
Copy link
Copy Markdown
Member Author

What an epic.

dependency-updates branch rebased-hard to main after merge of #20753 and pushed out so it's clean
Local rebase onto dependency-updates then squash done, ready for merge into dependency-updates branch

Pending CI

@mikehardy mikehardy added Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) and removed Needs Author Reply Waiting for a reply from the original author squash-merge A squash & force push is required. The PR author may do this to speed up the merge process. labels Apr 16, 2026
This is a squash of a 13-commit series, full commits messages follow:

----

chore: AGP9 has kotlin built in, so applying it as plugin is redundant

chore: AGP9 requires specific enable directive to use custom res values in defaultConfig

the value defaulted to true previously, but with AGP9 the default changed to false with
the change entry indicating that it should be enabled only for modules that definitely need it

AnkiDroid module needs it to allow for parallel build app name changing with CLI flags

https://developer.android.com/build/releases/agp-9-0-0-release-notes#android-gradle-plugin-behavior-changes

lint: AGP9 flags up a few new warnings for nullability and types

chore: AGP9 no longer allows -dontoptimize, forces use of optimize proguard

also there was no consumer-rules.pro file for libanki, and that's an error now,
remove the directive pointing to the non-existent file

chore: AGP9 forward-port to newly non-parameterized CommonExtension gradle object

style: delint build file spacing / some nullability differences

all from IDE suggestion

chore: AGP9 defers more configuration and debugPlayUnitTest is not available in all contexts

instead of a more-or-less concrete reference to the task - which may not exist / be configured
depending on the context, iterate over available tasks and do the configuration if the desired
name exists

build(deps): Android Gradle Plugin v9

pinned to v9.0.1 until upstream issue is resolved: https://issuetracker.google.com/issues/491718901

FAILURE: Build failed with an exception.

* What went wrong:
Circular dependency between the following tasks:
:AnkiDroid:l8DexDesugarLibPlayRelease
\--- :AnkiDroid:l8DexDesugarLibPlayReleaseAndroidTest
     \--- :AnkiDroid:minifyPlayReleaseAndroidTestWithR8
          \--- :AnkiDroid:l8DexDesugarLibPlayRelease (*)

(*) - details omitted (listed previously)

build(deps): bump com.github.triplet.play from 3.13.0 to 4.0.0

Bumps com.github.triplet.play from 3.13.0 to 4.0.0.

---
updated-dependencies:
- dependency-name: com.github.triplet.play
  dependency-version: 4.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

build: disable android.newDsl until keeper plugin is AGP9-compatible

build(deps): add version ref for kotlinx-coroutines-core dep

chore: forward-port to new android library module build config style

the configuration method lives on a different object now, otherwise is mostly same

kotlin sub-blocks should be promoted outside though, so moved those

chore: AGP9 w/built-in kotlin defaults JvmTarget to android.compileOptions.targetCompatibility

we no longer need to specify kotlin compile options related to JvmTarget, as the
built-in should handle that for us, chained to the android.compileOptions target,
this is a bonus from a "don't repeaty yourself" perspective so we should take advantage

https://developer.android.com/build/migrate-to-built-in-kotlin#migration-steps-migrate-kotlin-options

> Note: With built-in Kotlin, you don't need to set kotlin.compilerOptions.jvmTarget because its value defaults to android.compileOptions.targetCompatibility.

chore: AGP9 fix emulator test class file location
@mikehardy mikehardy changed the base branch from dependency-updates to main April 16, 2026 18:19
@mikehardy mikehardy enabled auto-merge April 16, 2026 18:20
@mikehardy mikehardy added this pull request to the merge queue Apr 16, 2026
Merged via the queue into ankidroid:main with commit 28fbdb1 Apr 16, 2026
10 checks passed
@github-actions github-actions Bot added this to the 2.24 release milestone Apr 16, 2026
@github-actions github-actions Bot removed the Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) label Apr 16, 2026
@mikehardy mikehardy deleted the agp9 branch April 16, 2026 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies used for automated dependency PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants