[Android] Do not set explicit versions in build.gradle #4248
Conversation
| } | ||
| ``` | ||
|
|
||
| Gesture Handler on Android is implemented in Kotlin. If you need to set a specific Kotlin version to be used by the library, set the `kotlinVersion` ext property in the `android/build.gradle` file and RNGH will use that version: |
There was a problem hiding this comment.
I'm not sure if we want to remove it entirely, or add info that it is not supported anymore (e.g. starting from 3.1.0)
There was a problem hiding this comment.
Pull request overview
This PR reduces Android build warnings about the Kotlin Gradle plugin being loaded multiple times by avoiding adding an explicit kotlin-gradle-plugin classpath dependency when the root project already provides it. It also updates the installation docs to remove guidance about forcing a specific Kotlin version for RNGH.
Changes:
- Conditionally adds
org.jetbrains.kotlin:kotlin-gradle-pluginto thebuildscriptclasspath only when the root project does not already include it. - Removes the documentation section describing how to override RNGH’s Kotlin version via
ext.kotlinVersion.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/react-native-gesture-handler/android/build.gradle | Adds a root-project classpath check to avoid explicitly loading the Kotlin Gradle plugin when it’s already provided. |
| packages/docs-gesture-handler/docs/fundamentals/installation.mdx | Removes Kotlin-version override instructions from the Android installation docs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
build.gradle build.gradle
| classpath("com.android.tools.build:gradle:8.10.1") | ||
| classpath("com.diffplug.spotless:spotless-plugin-gradle:7.0.4") | ||
| if (project == rootProject) { | ||
| def kotlin_version = project.properties['RNGH_kotlinVersion'] |
There was a problem hiding this comment.
Can you also update that version? RN is at 2.1.20, while we have 2.0.21 set here.
There was a problem hiding this comment.
Bumped Kotlin to 2.2.0 as in template and react native main
…react-native-gesture-handler into @mbert/dont-pin-kotlin
…4146) ## Description <!-- Description and motivation for this PR. This section should include "what & why". Please link all related issues that merging this PR should close, by using the `Closes #<issue-number>` syntax. For example: Closes #12345. --> This PR is a follow up for the [PR from Gesture Handler side](software-mansion/react-native-gesture-handler#4248). In [this issue](software-mansion/react-native-gesture-handler#2307) in our repository it was stated that there are warnings during build phase, namely both, Screens and Gesture Handler try to load their pinned versions of Kotlin. ## Changes <!-- This is "how" of the PR description. Please describe things you've changed here, make a **high level** overview, if change is simple you can omit this section. For example: - Updated `about.md` docs --> To address aforementioned issue, I've added simple `if` statement that adds pinned versions to classpath only if Screens is the root project (e.g. when running `spotless`). Both, `gradle` and `kotlin-gradle-plugin` are shipped with React Native apps ([see template](https://github.com/react-native-community/template/blob/816967c82f535cacc0f7a5c28688e884ecc3bdd9/template/android/build.gradle#L14)) so it is not necessary to declare them. This could break before RN 0.70, but I don't think that it is relevant at this point. ## Test plan Tested that `FabricExample` and standalone app with Screens added from generated package build correctly. ## Checklist - [ ] Included code example that can be used to test this change. - [ ] For visual changes, included screenshots / GIFs / recordings documenting the change. - [ ] For API changes, updated relevant public types. - [ ] Ensured that CI passes --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: Kacper Kafara <kacperkafara@gmail.com>
Description
Gesture Handler loads specific Kotlin version during build. This is unnecessary and may cause build warnings, such as one described in #2307.
This PR removes pinning of specific kotlin/gradle versions when Gesture Handler is not root project, so we fallback to the ones declared by the root. Unfortunately we can't simply remove those lines, as
spotlesswould fail.Fixes #2307
Test plan
Tested that android build correctly in basic-example, expo-example and standalone app.