chore: upgrade to Gradle 9.7.1 and AGP 9.4.0 - #28
Conversation
The build machine runs JDK 26, which Gradle 8.13 and AGP 8.6.1 cannot parse - the build fails with "26.0.1" as the entire error message, before reaching any task. Rather than pin that machine to an older JDK, move the toolchain forward. AGP 9 required three changes: - android.libraryVariants is gone. The AAR rename now runs from androidComponents.onVariants, and matches the bundle task by name because AGP 9 does not create one for every variant. - Library variants are no longer publishable implicitly, so the publish plugin is told which variant to publish. Called on the extension explicitly, since a bare configure() in a Groovy script resolves to Project.configure. - publishToMavenCentral no longer takes a SonatypeHost; the Central Portal is the only host it publishes to now. That needed the publish plugin at 0.37.0. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013vehBwh7WFaVQiawtJa7AN
There was a problem hiding this comment.
🟡 Changes recommended
The updated gradlew.bat does not reliably terminate on “no Java / invalid JAVA_HOME” error paths, so it can continue executing after printing an error.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Upgrades the project’s build tooling (Gradle wrapper + Android Gradle Plugin + Vanniktech publish plugin) to support running on JDK 26.0.1, and updates the AAR renaming/publishing wiring for AGP 9 breaking changes.
Changes:
- Bump Gradle wrapper to 9.7.1 and update generated
gradlew/gradlew.batscripts. - Bump AGP to 9.4.0 and
com.vanniktech.maven.publishto 0.37.0 via the version catalog. - Update
app/build.gradleto useandroidComponents.onVariantsfor AAR renaming and adjust the publish configuration for AGP 9.
File summaries
| File | Description |
|---|---|
| gradlew.bat | Updated Windows wrapper script for Gradle 9.7.1 (found an early-exit bug). |
| gradlew | Updated POSIX wrapper script for Gradle 9.7.1. |
| gradle/wrapper/gradle-wrapper.properties | Points wrapper to Gradle 9.7.1 and adds wrapper network settings. |
| gradle/libs.versions.toml | Updates AGP and maven publish plugin versions. |
| app/build.gradle | Updates publishing config and switches AAR renaming to androidComponents.onVariants for AGP 9. |
Review details
Suppressed comments (1)
gradlew.bat:68
- Same issue here:
"%COMSPEC%" /c exit 1does not terminate the current gradlew.bat process, so the script can continue on to:executewith an invalid JAVA_HOME and fail later with a less clear error.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
"%COMSPEC%" /c exit 1
- Files reviewed: 5/6 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| echo. 1>&2 | ||
| echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 | ||
| echo. 1>&2 | ||
| echo Please set the JAVA_HOME variable in your environment to match the 1>&2 | ||
| echo location of your Java installation. 1>&2 | ||
|
|
||
| goto fail | ||
| "%COMSPEC%" /c exit 1 |
There was a problem hiding this comment.
Declined — gradlew.bat is generated, not hand-written.
The claim about batch semantics is correct: "%COMSPEC%" /c exit 1 sets ERRORLEVEL in a child cmd and execution continues, so with no JAVA_HOME and no java on PATH the script prints the first error, falls into :findJavaFromJavaHome, prints the second, then reaches :execute. The process still terminates non-zero via "%COMSPEC%" /c exit %ERRORLEVEL% on line 82, so the failure is reported — the cost is a confusing second error message, not a false success.
But this file is produced verbatim by Gradle 9.7.1's wrapper task. Re-running ./gradlew wrapper --gradle-version 9.7.1 on this branch reproduces the committed file byte-for-byte, so any hand-edit here would be silently reverted the next time anyone regenerates the wrapper, and would leave the repo diverged from the script Gradle ships and verifies.
It shows up in this diff only because the wrapper moved from 8.13 to 9.7.1 — origin/main's gradlew.bat contains no COMSPEC lines at all. If the fall-through is worth fixing it belongs upstream in gradle/gradle, not in this PR.
Why
The build machine runs JDK 26.0.1, which Gradle 8.13 and AGP 8.6.1 cannot parse. The build dies during startup with the version string as its entire error message:
Pinning that machine to an older JDK would work, but the toolchain is a year behind and the next release has to come off that machine.
Gradle
8.13→9.7.1, AGP8.6.1→9.4.0,com.vanniktech.maven.publish0.30.0→0.37.0(older versions do not support AGP 9).AGP 9 breaking changes handled here
android.libraryVariantswas removed. The AAR rename that producesbugsplat-android-release.aarnow runs fromandroidComponents.onVariants. It matches the bundle task by name rather than callingtasks.named(...), because AGP 9 does not createbundleDebugAar— naming it directly throwsUnknownTaskException.Library variants are no longer publishable implicitly.
Unable to find variant to publish named releaseuntil the plugin is told which variant to publish. Note the call isdelegate.configure(...): a bareconfigure(...)inside themavenPublishingblock resolves toProject.configurein a Groovy build script and silently does nothing. Declaringpublishing { singleVariant('release') }in theandroidblock instead fails withUsing singleVariant publishing DSL multiple times, since the plugin already declares it.publishToMavenCentralno longer takes aSonatypeHost. The Central Portal is the only host it publishes to now, so the argument was removed — leaving it producesCould not get unknown property 'com'.Verification
:app:assembleRelease:app:testDebugUnitTest:example:compileDebugJavaWithJavacbugsplat-android-release.aarrenamelibbugsplat_handler.sopackagedThat last row matters: the handler wrapper from #26 is new native output, and the AAR rename and CMake packaging are exactly what the AGP upgrade touches.
Not verified: publishing.
publishToMavenLocalfails here withNo configured signatory— no PGP key on this machine. The publish configuration is only proven as far as configuration time; whoever holds the key should run./gradlew publishToMavenLocalon this branch before it merges, since the publish DSL changed.Not included
1.9.0. The plugin is declared in the version catalog but applied nowhere, and the only.ktfiles are unused template tests. Bumping or removing it is a separate cleanup.gradlew/gradlew.bat/gradle-wrapper.jarare regenerated by./gradlew wrapper, so the diff includes them.