Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: patch react-native-screens build.gradle to solve build issue #5684

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
"react-native-responsive-screen": "^1.4.1",
"react-native-safe-area-context": "^3.3.2",
"react-native-screen-brightness": "^2.0.0-alpha",
"react-native-screens": "^3.30.1",
"react-native-screens": "3.30.1",
"react-native-sha256": "1.2.3",
"react-native-share": "7.3.9",
"react-native-splash-screen": "^3.2.0",
Expand Down
10 changes: 9 additions & 1 deletion patches/patches.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,12 @@ Created on **16/01/2023**
- This patch fixes a crash on Android devices when trying to find/create/remove calendar events.
An Event has an Id property which type may be a long but the library deals only with Java's signed int32.
This was fine as long as each event was originally created and handled using this library only but
initially another library was used, react-native-add-calendar-event, which treated event's Id as long
initially another library was used, react-native-add-calendar-event, which treated event's Id as long

### react-native-screens+3.30.1.patch

Created on **12/04/2024**

#### Reason:

- This patch fixes an issue introduced by the library update that return an error during the build of the app on android device. The issue has been fixed in the release of the library `3.31.0` but it's still on a pre-release stage. We are waiting for the release of the library to remove the patch.
138 changes: 138 additions & 0 deletions patches/react-native-screens+3.30.1.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
diff --git a/node_modules/react-native-screens/android/build.gradle b/node_modules/react-native-screens/android/build.gradle
index c2ecc16..6c20ed2 100644
--- a/node_modules/react-native-screens/android/build.gradle
+++ b/node_modules/react-native-screens/android/build.gradle
@@ -46,6 +46,38 @@ def reactNativeArchitectures() {
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
}

+def safeAppExtGet(prop, fallback) {
+ def appProject = rootProject.allprojects.find { it.plugins.hasPlugin('com.android.application') }
+ appProject?.ext?.has(prop) ? appProject.ext.get(prop) : fallback
+}
+
+def resolveReactNativeDirectory() {
+ def reactNativeLocation = safeAppExtGet("REACT_NATIVE_NODE_MODULES_DIR", null)
+ if (reactNativeLocation != null) {
+ return file(reactNativeLocation)
+ }
+
+ def reactNativeFromAppNodeModules = file("${projectDir}/../../react-native")
+ if (reactNativeFromAppNodeModules.exists()) {
+ return reactNativeFromAppNodeModules
+ }
+
+ def reactNativeFromProjectNodeModules = file("${rootProject.projectDir}/../node_modules/react-native")
+ if (reactNativeFromProjectNodeModules.exists()) {
+ return reactNativeFromProjectNodeModules
+ }
+
+ throw new GradleException(
+ "[RNScreens] Unable to resolve react-native location in node_modules. You should project extension property (in `app/build.gradle`) `REACT_NATIVE_NODE_MODULES_DIR` with path to react-native."
+ )
+}
+
+def reactNativeRootDir = resolveReactNativeDirectory()
+def reactProperties = new Properties()
+file("$reactNativeRootDir/ReactAndroid/gradle.properties").withInputStream { reactProperties.load(it) }
+def REACT_NATIVE_VERSION = reactProperties.getProperty("VERSION_NAME")
+def REACT_NATIVE_MINOR_VERSION = REACT_NATIVE_VERSION.startsWith("0.0.0-") ? 1000 : REACT_NATIVE_VERSION.split("\\.")[1].toInteger()
+
android {
compileSdkVersion safeExtGet('compileSdkVersion', rnsDefaultCompileSdkVersion)
def agpVersion = Version.ANDROID_GRADLE_PLUGIN_VERSION
@@ -80,12 +112,14 @@ android {
}
}
}
- buildFeatures {
- prefab true
- }
- externalNativeBuild {
- cmake {
- path "CMakeLists.txt"
+ if (REACT_NATIVE_MINOR_VERSION >= 71) {
+ buildFeatures {
+ prefab true
+ }
+ externalNativeBuild {
+ cmake {
+ path "CMakeLists.txt"
+ }
}
}
lintOptions {
@@ -146,11 +180,11 @@ repositories {

dependencies {
implementation 'com.facebook.react:react-native:+'
- implementation 'androidx.appcompat:appcompat:1.5.0'
+ implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'androidx.fragment:fragment:1.3.6'
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.2.0'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
- implementation 'com.google.android.material:material:1.9.0'
+ implementation 'com.google.android.material:material:1.6.1'
implementation "androidx.core:core-ktx:1.8.0"

constraints {
diff --git a/node_modules/react-native-screens/gesture-handler/package.json b/node_modules/react-native-screens/gesture-handler/package.json
index 282b21b..3b244ad 100644
--- a/node_modules/react-native-screens/gesture-handler/package.json
+++ b/node_modules/react-native-screens/gesture-handler/package.json
@@ -1,6 +1,13 @@
{
"main": "../lib/commonjs/gesture-handler/index",
"module": "../lib/module/gesture-handler/index",
- "react-native": "../src/gesture-handler/index",
- "types": "../lib/typescript/gesture-handler/index"
+ "react-native": {
+ "../lib/commonjs/gesture-handler/index": "../src/gesture-handler/index",
+ "path": "path-browserify"
+ },
+ "types": "../lib/typescript/gesture-handler/index",
+ "browser": {
+ "../lib/commonjs/gesture-handler/index": "../src/gesture-handler/index",
+ "path": "path-browserify"
+ }
}
diff --git a/node_modules/react-native-screens/native-stack/package.json b/node_modules/react-native-screens/native-stack/package.json
index 6d82f6a..08ee459 100644
--- a/node_modules/react-native-screens/native-stack/package.json
+++ b/node_modules/react-native-screens/native-stack/package.json
@@ -1,6 +1,13 @@
{
"main": "../lib/commonjs/native-stack/index",
"module": "../lib/module/native-stack/index",
- "react-native": "../src/native-stack/index",
- "types": "../lib/typescript/native-stack/index.d.ts"
+ "react-native": {
+ "../lib/commonjs/native-stack/index": "../src/native-stack/index",
+ "path": "path-browserify"
+ },
+ "types": "../lib/typescript/native-stack/index.d.ts",
+ "browser": {
+ "../lib/commonjs/native-stack/index": "../src/native-stack/index",
+ "path": "path-browserify"
+ }
}
diff --git a/node_modules/react-native-screens/reanimated/package.json b/node_modules/react-native-screens/reanimated/package.json
index 55fece0..9d97835 100644
--- a/node_modules/react-native-screens/reanimated/package.json
+++ b/node_modules/react-native-screens/reanimated/package.json
@@ -1,6 +1,13 @@
{
"main": "../lib/commonjs/reanimated/index",
"module": "../lib/module/reanimated/index",
- "react-native": "../src/reanimated/index",
- "types": "../lib/typescript/reanimated/index.d.ts"
+ "react-native": {
+ "../lib/commonjs/reanimated/index": "../src/reanimated/index",
+ "path": "path-browserify"
+ },
+ "types": "../lib/typescript/reanimated/index.d.ts",
+ "browser": {
+ "../lib/commonjs/reanimated/index": "../src/reanimated/index",
+ "path": "path-browserify"
+ }
}
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14706,7 +14706,7 @@ react-native-screen-brightness@^2.0.0-alpha:
resolved "https://registry.yarnpkg.com/react-native-screen-brightness/-/react-native-screen-brightness-2.0.0-alpha.tgz#2fc30cf711cfafa5e0aec685f0fce51ce65e0052"
integrity sha512-NdJPptcWiFwG9aypm0awYv9d/aoZSJetXPFkx6w/UuNX9SRr5YTKXMSND/2lwuSOw6uGU9mQ0f4dBuGZSNgzow==

react-native-screens@^3.30.1:
react-native-screens@3.30.1:
version "3.30.1"
resolved "https://registry.yarnpkg.com/react-native-screens/-/react-native-screens-3.30.1.tgz#254f5cbbeed649492da112756f85ecae3ccf313e"
integrity sha512-/muEvjocCtFb+j5J3YmLvB25+f4rIU8hnnxgGTkXcAf2omPBY8uhPjJaaFUlvj64VEoEzJcRpugbXWsjfPPIFg==
Expand Down
Loading