Skip to content

feat: Adopt AGP v9 - #4263

Open
hurali97 wants to merge 3 commits into
software-mansion:mainfrom
hurali97:feat/agp9
Open

feat: Adopt AGP v9#4263
hurali97 wants to merge 3 commits into
software-mansion:mainfrom
hurali97:feat/agp9

Conversation

@hurali97

@hurali97 hurali97 commented Jun 16, 2026

Copy link
Copy Markdown

Description

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-gesture-handler/android/build.gradle. The rest of the changes can be considered temporary.

The rest changes include:

  • Making Basic Example App AGP9 compliant
  • Upgrade Gradle to v9.4.1
  • Use proguard-android-optimize proguard file
  • 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 Basic 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 Reanimated and Worklet, making those AGP v9 compliant and removing the opt outs to test the changes in the PR
agp-9.mp4
Verified these changes work with AGP 8
agp-8.mov

Copilot AI review requested due to automatic review settings June 16, 2026 09:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Updates Android build tooling and adjusts React Native Gesture Handler’s Android Gradle configuration to work across newer AGP/Kotlin setups.

Changes:

  • Bump Gradle wrapper to 9.4.1 in the library package and the basic example app.
  • Add AGP-version/property-based fallback to apply kotlin-android only when needed.
  • Rework sourceSets.main configuration to use a Kotlin-specific source set API.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
packages/react-native-gesture-handler/android/gradle/wrapper/gradle-wrapper.properties Updates Gradle wrapper version for the gesture handler Android project.
packages/react-native-gesture-handler/android/build.gradle Adds AGP/Kotlin fallback logic and changes source set configuration.
apps/basic-example/android/gradle/wrapper/gradle-wrapper.properties Updates Gradle wrapper version for the example app.
apps/basic-example/android/gradle.properties Adds properties to opt out of AGP built-in Kotlin and new DSL behavior.
apps/basic-example/android/app/build.gradle Switches default ProGuard config to the optimized variant for release builds.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/react-native-gesture-handler/android/build.gradle
Comment thread packages/react-native-gesture-handler/android/build.gradle
Comment thread apps/basic-example/android/gradle/wrapper/gradle-wrapper.properties
Comment thread apps/basic-example/android/gradle.properties
@hurali97
hurali97 marked this pull request as ready for review June 16, 2026 10:31
@m-bert
m-bert requested a balanced review from Copilot August 12, 2026 13:55
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Improved Android build compatibility for projects using newer Android Gradle Plugin versions.
    • Updated Kotlin source integration for Reanimated and SVG features.

Walkthrough

The Android build configuration now conditionally applies the Kotlin plugin and registers Reanimated and SVG integration paths as Kotlin source directories.

Changes

Android Kotlin build configuration

Layer / File(s) Summary
Conditional Kotlin plugin application
packages/react-native-gesture-handler/android/build.gradle
The build applies kotlin-android only for AGP 8 or earlier, or when built-in Kotlin is disabled.
Kotlin integration source directories
packages/react-native-gesture-handler/android/build.gradle
Reanimated and SVG integration paths now use kotlin.directories.add instead of java.srcDirs +=.

Suggested reviewers: m-bert

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary change: adopting AGP v9 for React Native Gesture Handler.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/react-native-gesture-handler/android/build.gradle`:
- Around line 219-229: Update the kotlin source-directory configuration to
preserve AGP 8.0–8.4 compatibility: replace the unconditional directories.add
calls in the shouldUseCommonInterfaceFromReanimated and
shouldUseCommonInterfaceFromRNSVG branches with srcDirs, or guard
directories.add behind a full AGP-version check that requires 8.5.0 or newer.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d2884032-3d2f-444a-b40d-ff887924e43f

📥 Commits

Reviewing files that changed from the base of the PR and between bd85331 and 8ce791c.

📒 Files selected for processing (1)
  • packages/react-native-gesture-handler/android/build.gradle

Comment thread packages/react-native-gesture-handler/android/build.gradle
@m-bert

m-bert commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Hi @hurali97! I took the liberty of updating this PR, could you please take a look and confirm that we can merge? 😅

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.

4 participants