@@ -11,8 +11,8 @@ buildscript {
1111
1212 dependencies {
1313 classpath(" org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version " )
14- classpath(" com.android.tools.build:gradle:7.2 .1" )
15- classpath(" com.diffplug.spotless:spotless-plugin-gradle:7.0.3 " )
14+ classpath(" com.android.tools.build:gradle:8.10 .1" )
15+ classpath(" com.diffplug.spotless:spotless-plugin-gradle:7.0.4 " )
1616 }
1717}
1818
@@ -45,6 +45,7 @@ def resolveReactNativeDirectory() {
4545 commandLine(" node" , " --print" , " require.resolve('react-native/package.json')" )
4646 }. standardOutput. asText. get(). trim()
4747 )
48+
4849 if (reactNativePackage. exists()) {
4950 return reactNativePackage. parentFile
5051 }
@@ -59,41 +60,53 @@ def resolveReactNativeDirectory() {
5960if (isNewArchitectureEnabled()) {
6061 apply plugin : ' com.facebook.react'
6162}
63+
6264apply plugin : ' com.android.library'
6365apply plugin : ' kotlin-android'
6466
6567if (project == rootProject) {
6668 apply from : " spotless.gradle"
6769}
6870
71+ def getExternalLibVersion (project ){
72+ def inputFile = new File (project. projectDir, " ../package.json" )
73+ def json = new JsonSlurper (). parseText(inputFile. text)
74+ def libVerision = json. version as String
75+ def (major, minor, patch) = libVerision. tokenize(' .' )
76+
77+ // Handle cases where version is a pre-release one, e.g. "2.3.0-alpha.1"
78+ def patchVersion = patch. find(/ (\d +)/ ) ? patch. find(/ (\d +)/ ) : " 0"
79+
80+ return [Integer . parseInt(major), Integer . parseInt(minor), Integer . parseInt(patchVersion)]
81+ }
82+
6983// Check whether Reanimated 2.3 or higher is installed alongside Gesture Handler
7084def shouldUseCommonInterfaceFromReanimated () {
7185 def reanimated = rootProject. subprojects. find { it. name == ' react-native-reanimated' }
72- if (reanimated != null ) {
73- def inputFile = new File (reanimated. projectDir, ' ../package.json' )
74- def json = new JsonSlurper (). parseText(inputFile. text)
75- def reanimatedVersion = json. version as String
76- def (major, minor, patch) = reanimatedVersion. tokenize(' .' )
77- return (Integer . parseInt(major) == 2 && Integer . parseInt(minor) >= 3 ) || Integer . parseInt(major) >= 3
78- } else {
86+
87+ if (reanimated == null ) {
7988 return false
8089 }
90+
91+ def (major, minor, patch) = getExternalLibVersion(reanimated)
92+
93+ return (major == 2 && minor >= 3 ) || major >= 3
8194}
8295
8396def shouldUseCommonInterfaceFromRNSVG () {
8497 // common interface compatible with react-native-svg >= 15.11.2
8598 def rnsvg = rootProject. subprojects. find { it. name == ' react-native-svg' }
99+
86100 if (rnsvg == null ) {
87101 return false
88102 }
89103
90- def inputFile = new File (rnsvg. projectDir, ' ../package.json' )
91- def json = new JsonSlurper (). parseText(inputFile. text)
92- def rnsvgVersion = json. version as String
93- def (major, minor, patch) = rnsvgVersion. tokenize(' .' )
94- return (Integer . parseInt(major) == 15 && Integer . parseInt(minor) == 11 && Integer . parseInt(patch) >= 2 ) ||
95- (Integer . parseInt(major) == 15 && Integer . parseInt(minor) > 11 ) ||
96- Integer . parseInt(major) > 15
104+ def (major, minor, patch) = getExternalLibVersion(rnsvg)
105+
106+
107+ return (major == 15 && minor == 11 && patch >= 2 ) ||
108+ (major == 15 && minor > 11 ) ||
109+ major > 15
97110}
98111
99112def reactNativeArchitectures () {
@@ -107,7 +120,7 @@ def reactProperties = new Properties()
107120file(" $REACT_NATIVE_DIR /ReactAndroid/gradle.properties" ). withInputStream { reactProperties. load(it) }
108121
109122def REACT_NATIVE_VERSION = reactProperties. getProperty(" VERSION_NAME" )
110- def REACT_NATIVE_MINOR_VERSION = REACT_NATIVE_VERSION . startsWith( " 0.0.0- " ) ? 1000 : REACT_NATIVE_VERSION . split(" \\ ." )[1 ]. toInteger()
123+ def REACT_NATIVE_MINOR_VERSION = REACT_NATIVE_VERSION . split(" \\ ." )[1 ]. toInteger()
111124
112125repositories {
113126 mavenCentral()
@@ -116,7 +129,7 @@ repositories {
116129android {
117130 compileSdkVersion safeExtGet(" compileSdkVersion" , 33 )
118131
119- namespace " com.swmansion.gesturehandler"
132+ namespace = " com.swmansion.gesturehandler"
120133 buildFeatures {
121134 buildConfig = true
122135 prefab = true
@@ -132,10 +145,8 @@ android {
132145 }
133146
134147 defaultConfig {
135- minSdkVersion safeExtGet(' minSdkVersion' , 21 )
148+ minSdkVersion safeExtGet(' minSdkVersion' , 24 )
136149 targetSdkVersion safeExtGet(' targetSdkVersion' , 33 )
137- versionCode 1
138- versionName " 1.0"
139150 buildConfigField " boolean" , " IS_NEW_ARCHITECTURE_ENABLED" , isNewArchitectureEnabled(). toString()
140151 buildConfigField " int" , " REACT_NATIVE_MINOR_VERSION" , REACT_NATIVE_MINOR_VERSION . toString()
141152
@@ -180,12 +191,9 @@ android {
180191
181192 sourceSets. main {
182193 java {
183- // Include "common/" only when it's not provided by Reanimated to mitigate
184- // multiple definitions of the same class preventing build
185194 if (shouldUseCommonInterfaceFromReanimated()) {
186195 srcDirs + = ' reanimated/src/main/java'
187196 } else {
188- srcDirs + = ' common/src/main/java'
189197 srcDirs + = ' noreanimated/src/main/java'
190198 }
191199
@@ -200,21 +208,7 @@ android {
200208 } else {
201209 // 'paper/src/main/java' includes files from codegen so the library can compile with
202210 // codegen turned off
203-
204- if (REACT_NATIVE_MINOR_VERSION > 77 ) {
205- srcDirs + = ' paper/src/main/java'
206- } else {
207- srcDirs + = ' paper77/src/main/java'
208- }
209- }
210-
211- if (REACT_NATIVE_MINOR_VERSION >= 77 ) {
212- // With RN 0.77, ViewManager related functions in the package has different signatures as they
213- // are no longer nullable
214- srcDirs + = ' package77/src/main/java'
215- } else {
216- // It's safe to delete this block once we drop support for RN 0.76
217- srcDirs + = ' packageDeprecated/src/main/java'
211+ srcDirs + = ' paper/src/main/java'
218212 }
219213 }
220214 }
@@ -252,7 +246,7 @@ dependencies {
252246 implementation rootProject. subprojects. find { it. name == ' react-native-svg' }
253247 }
254248
255- implementation ' androidx.appcompat:appcompat:1.2 .0'
256- implementation " androidx.core:core-ktx:1.6 .0"
249+ implementation ' androidx.appcompat:appcompat:1.7 .0'
250+ implementation " androidx.core:core-ktx:1.16 .0"
257251 implementation " org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version "
258252}
0 commit comments