feat: adopt AGP v9#57038
Open
hurali97 wants to merge 6 commits into
Open
Conversation
hurali97
commented
Jun 3, 2026
| androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidx-appcompat" } | ||
| androidx-appcompat-resources = { module = "androidx.appcompat:appcompat-resources", version.ref = "androidx-appcompat" } | ||
| androidx-autofill = { module = "androidx.autofill:autofill", version.ref = "androidx-autofill" } | ||
| androidx-collection = { module = "androidx.collection:collection", version.ref = "androidx-collection" } |
Contributor
Author
cortinico
requested changes
Jun 3, 2026
| distributionBase=GRADLE_USER_HOME | ||
| distributionPath=wrapper/dists | ||
| distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.1-bin.zip | ||
| distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip |
Contributor
There was a problem hiding this comment.
Can you send us a standalone PR with the Gradle bump only?
| distributionBase=GRADLE_USER_HOME | ||
| distributionPath=wrapper/dists | ||
| distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.1-bin.zip | ||
| distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip |
Comment on lines
+678
to
+681
| tasks.withType<JavaCompile>().configureEach { | ||
| exclude("com/facebook/react/processing/**") | ||
| exclude("com/facebook/react/module/processing/**") | ||
| } |
Contributor
There was a problem hiding this comment.
Why this? This should not be necessary at all
Comment on lines
-7
to
-12
| # Those 2 properties are needed to make our project compatible with | ||
| # AGP 9.0.0 for the time being. Ideally we should not opt-out of | ||
| # builtInKotlin and newDsl once AGP 9.0.0 hits stable. | ||
| # More on this: https://developer.android.com/build/releases/agp-preview#android-gradle-plugin-built-in-kotlin | ||
| android.builtInKotlin=false | ||
| android.newDsl=false |
Contributor
There was a problem hiding this comment.
Are we good removing those?
| api(libs.androidx.appcompat) | ||
| api(libs.androidx.appcompat.resources) | ||
| api(libs.androidx.autofill) | ||
| api(libs.androidx.collection) |
Contributor
There was a problem hiding this comment.
I'm not a huge fan of this becoming an api dependency. Can this be an implementation dep instead?
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.

Summary:
This PR is part of Android Gradle Plugin v9 adoption. With this PR, we adopt the AGP9 repository wide and address the deprecated APIs with the newer ones.
This is in combination with #57038
Changes to `configureBuildConfigFieldsForLibraries` and `configureNamespaceForLibraries`
These helpers are called from `ReactPlugin.apply`, but they currently iterate over `rootProject.allprojects`. Since `com.facebook.react` is applied by multiple Android library projects, each application of the plugin repeats the same traversal and attempts to register `finalizeDsl` callbacks for every Android library project.
The first traversal can register the callbacks successfully. However, a later traversal can reach a project whose Android DSL finalization phase has already completed. Starting with AGP 9, AGP explicitly errors when
finalizeDslis called after that phase has passed, which causes the build failure. seeTo understand this, consider following modules:
The current code on main, would result in executing the following block 3 times:
The output would be:
Now with AGP9, the same code will throw this error:
Solution:
Since these helpers are only intended to configure Android library projects that apply the React plugin, we can configure the current project inside
pluginManager.withPlugin("com.android.library")instead of repeatedly configuring all projects from every plugin application.One important note for
configureNamespaceForLibrariesis that the oldcom.android.build.gradle.LibraryExtensionis deprecated in favor ofcom.android.build.api.dsl.LibraryExtension- which does not exposemanifestFilefrom thesourceSets. So we have to define a path for it. For most libraries, this should be OK but for the ones which define custom path, this will fail.Hence, I believe, if it's important to have this fallback, we take this tradeoff. Otherwise, since there has been 2 years passed for AGP8 adoption and the time when this fallback was added, we may safely remove this function as almost all libraries now define a
namespaceinandroid { }DSL.With the above in place, we make one final change and that is to move these two functions inside the
withPlugin("com.android.library")as these are only intended for libraries and that way, we also ensure that these will only be applied once thecom.android.libraryplugin has been applied.Changelog:
[ANDROID] [BREAKING] - Adopt AGP v9
Test Plan:
rn-tester.mp4