Repository navigation
Require Android Gradle Plugin 9 and Gradle 9.1 - #177
Merged
Merged
Conversation
rvandermeulen
force-pushed
the
agp-9
branch
4 times, most recently
from
November 11, 2026 03:55
9763338 to
9e9e664
Compare
segunfamisa
approved these changes
Nov 16, 2026
segunfamisa
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for this patch. It's my first review on this project, so I may be missing a lot of context, but this looks and reads correct to me.
I had only one minor and optional feedback comment.
AGP 9 no longer exposes BaseExtension, AppExtension or LibraryExtension, which the plugin configured through, so it now uses the androidComponents API: the default API level is the lowest minSdk of the variants, the jniLibs directory is added per variant, and the NDK directory comes from sdkComponents. Each variant's jniLibs merge and unit test tasks depend on cargoBuild, so changed Rust code always reaches the merged libraries without a hook in the consuming build (mozilla#166); the README drops the javaPreCompile hook it used to suggest, which never ordered cargoBuild before the merge. The desktop libraries go on each unit test task's classpath instead of the unit test Java resources, which AGP builds without .so files, so they now load on Linux hosts too. Per-target RUST_ANDROID_GRADLE_TARGET_ properties are read from the project's extra properties, since Project.getProperties fails in Gradle 10 and the providers API skips subproject gradle.properties and ext values. Values inherited from a parent project's ext are no longer read, matching Gradle's deprecation of that lookup, and the README says where an ext value has to go. The generateLinkerWrapper task is a plain Sync. Projects still on AGP 8 can stay on 0.10.0. The plugin compiles against the AGP 9.0.0 API with Kotlin 2.4 at the Kotlin 2.2 language and API level that Gradle 9.1 embeds, and still emits Java 17 bytecode. The build moves to Gradle 9.9.1, Spock 2.5 for Groovy 4 and current plugin-publish and test-retry. The version helpers used the removed org.gradle.util.VersionNumber and only serve the tests, so they move there with their Guava dependency, which the published plugin no longer carries. The test matrix covers AGP 9.0.0 on Gradle 9.1.0 and AGP 9.5.1 on Gradle 9.9.1, the test projects build against compileSdk 36 and NDK r30, CargoBuildTest now checks that merging the jniLibs runs cargoBuild and picks up the libraries, and pins the per-target task names, and CargoTargetTest builds the linux-x86-64 desktop target on Linux hosts. The README's cargo argument examples gain the TARGET_ prefix the plugin matches.
The applicationVariants and libraryVariants hooks go, since the plugin now orders cargoBuild before the jniLibs merge and unit tests. The release build types only restated the defaults and named proguard-android.txt, which AGP 9 rejects, so they go, along with the unused proguard-rules.pro. The samples build against compileSdk 36 and NDK r30. samples/unittest drops its Gradle 6.1.1 wrapper for the top-level one the other samples use, and moves to Robolectric 4.17 for SDK 36 with the JUnit 4.13.2 it requires.
The jobs installed NDK r21 and r23, which no test uses. The tests now default to r30. NdkVersionTest drops r28, which the Ubuntu and Windows runner images no longer carry, and covers r27, r29 and r30. The samples job also runs the samples/unittest unit tests on Linux.
CargoEnvironmentTest runs in the AGP version matrix and records cargo's environment through a RUSTC_WRAPPER passed in as a target property.
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.
AGP 9 removed BaseExtension, AppExtension and LibraryExtension, which the plugin used to configure itself, so this ports it to the
androidComponentsAPI. The plugin now requires AGP 9.0 or newer and Gradle 9.1 or newer. Projects still on AGP 8 can stay on 0.10.0.Behavior changes for consumers:
cargoBuild, so the Rust libraries are always built before they are packaged or loaded in unit tests. Builds no longer need their owndependsOn 'cargoBuild'hook.apiLevel/apiLevelsaren't set, the default API level is the lowestminSdkacross the variants, notdefaultConfig.minSdk..sofiles out of unit test Java resources, so desktop libraries now also load in unit tests on Linux hosts.RUST_ANDROID_GRADLE_TARGET_*properties are read from the project's extra properties, sinceProject.getPropertiesfails in Gradle 10. Gradle properties from every source still work, including a subproject'sgradle.properties. A value set withextin a parent project is no longer inherited; it has to be set in the project that applies the plugin, or throughallprojects.android.sourceSets.main.jniLibs.generateLinkerWrapperis a plainSynctask, and theGenerateLinkerWrapperTaskclass is gone.The build moves to Gradle 9.9.1 and Kotlin 2.4, still targeting the Kotlin 2.2 API (what Gradle 9.1 embeds) and Java 17 bytecode. CI moves to JDK 25 and NDK r30.
Tests:
linux-x86-64desktop target on Linux.mergeDebugJniLibFoldersand checks that it pulls incargoBuild.samples/unittestunit tests on Linux.The README gets the AGP 9 requirement and corrected
RUST_ANDROID_GRADLE_TARGET_examples, and drops thejavaPreCompilehook it used to suggest, which never orderedcargoBuildbefore the merge.Fixes #43, fixes #85, fixes #166. This likely also addresses #118 and #147, which report the same task-ordering symptoms on older AGP versions.