Skip to content

feat: Adopt AGP v9#733

Open
hurali97 wants to merge 4 commits into
AppAndFlow:mainfrom
hurali97:feat/agp9
Open

feat: Adopt AGP v9#733
hurali97 wants to merge 4 commits into
AppAndFlow:mainfrom
hurali97:feat/agp9

Conversation

@hurali97

Copy link
Copy Markdown

Summary

Note: Merge this PR after #732

This PR is rasied following the second phase of the RFC around AGP v9 adoption:

RFC: react-native-community/discussions-and-proposals#1006

The gist of this PR is to make Gesture Handler AGP v9 compliant with backward compatibility. The main scope of changes is the react-native-safe-area-context/android/build.gradle. The rest of the changes can be considered temporary.

The rest changes include:

  • Making Example App AGP9 compliant
  • Upgrade Gradle to v9.4.1
  • Enable opt outs in the gradle.properties

Ideally, we should not enable the opt outs and leverage the AGP 9 built-in kotlin and newDSL. However, if we do not do it, then other libraries which are not yet AGP v9 compliant starts to fail. Hence, we need to keep the opt outs enabled for a while. For the context, react-native starting from 0.87.x will ship with AGP v9 and opt outs enabled by default for the new apps, which is the first phase of AGP v9 adoption.

With the second phase when the libraries starts adoption AGP v9, we can eventually remove the opt outs from Example.

Test Plan

To test this PR, we need to do a few steps:

  • Set the agp version to 9.2.1 and kotlin to 2.2.0 in react-native-gradle-plugin
--- a/node_modules/@react-native/gradle-plugin/gradle/libs.versions.toml
+++ b/node_modules/@react-native/gradle-plugin/gradle/libs.versions.toml
@@ -1,10 +1,10 @@
 [versions]
-agp = "8.12.0"
+agp = "9.2.1"
 gson = "2.8.9"

-kotlin = "2.1.20"
+kotlin = "2.2.0"
 assertj = "3.25.1"
  • Comment out the following functions in react-native-gradle-plugin
--- a/node_modules/@react-native/gradle-plugin/react-native-gradle-plugin/ReactPlugin.kt
+++ b/node_modules/@react-native/gradle-plugin/react-native-gradle-plugin/ReactPlugin.kt
@@ -1,10 +1,10 @@
      configureBuildTypesForApp(project)
    }

    // Library Only Configuration
-    configureBuildConfigFieldsForLibraries(project)
-    configureNamespaceForLibraries(project)
+    // configureBuildConfigFieldsForLibraries(project)
+    // configureNamespaceForLibraries(project)
    project.pluginManager.withPlugin("com.android.library") {

This step is only required because we have RN version on 0.85.2 and AGP + kotlin bump will be shipped with 0.87.x.

Verified by locally patching RN screens, async-storage etc., making those AGP v9 compliant and removing the opt outs to test the changes in the PR
agp-9.mov
Verified these changes work with AGP 8
agp-8.mov

@hurali97 hurali97 changed the title Feat/agp9 feat: Adopt AGP v9 Jun 22, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

AGP v9 changes

Comment thread android/build.gradle

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

AGP v9 changes

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

AGP v9 changes

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

AGP v9 changes

@hurali97

Copy link
Copy Markdown
Author

Added comments on the files which targets the scope of this PR, the rest changes will be gone once the linked PR is merged.

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.

1 participant