@@ -17,25 +17,19 @@ buildDir = "${rootDir}/${name}/build"
17
17
18
18
def reactNativePath = file(findNodeModulesPath(" react-native" , rootDir))
19
19
20
- if (autodetectReactNativeVersion || enableNewArchitecture) {
21
- apply(plugin : " com.facebook.react" )
22
-
23
- react {
24
- reactNativeDir = reactNativePath
25
- codegenDir = file(
26
- reactNativeVersion >= v(0 , 72 , 0 )
27
- ? findNodeModulesPath(" @react-native/codegen" , reactNativePath)
28
- : findNodeModulesPath(" react-native-codegen" , reactNativePath)
29
- )
30
- }
20
+ apply(plugin : " com.facebook.react" )
31
21
32
- // We don't want the React plugin to bundle.
33
- tasks. whenTaskAdded { task ->
34
- // The task name can be found in `react-native-gradle-plugin`:
35
- // https://github.com/facebook/react-native/blob/0.71-stable/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt#L54
36
- if (task. name. startsWith(" createBundle" ) && task. name. endsWith(" JsAndAssets" )) {
37
- task. enabled = false
38
- }
22
+ react {
23
+ reactNativeDir = reactNativePath
24
+ codegenDir = file(findNodeModulesPath(" @react-native/codegen" , reactNativePath))
25
+ }
26
+
27
+ // We don't want the React plugin to bundle.
28
+ tasks. whenTaskAdded { task ->
29
+ // The task name can be found in `react-native-gradle-plugin`:
30
+ // https://github.com/facebook/react-native/blob/0.71-stable/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt#L54
31
+ if (task. name. startsWith(" createBundle" ) && task. name. endsWith(" JsAndAssets" )) {
32
+ task. enabled = false
39
33
}
40
34
}
41
35
@@ -78,10 +72,8 @@ android {
78
72
ndkVersion = project. ext. ndkVersion
79
73
}
80
74
81
- if (usePrefabs) {
82
- buildFeatures {
83
- prefab = true
84
- }
75
+ buildFeatures {
76
+ prefab = true
85
77
}
86
78
87
79
kotlinOptions {
@@ -107,14 +99,12 @@ android {
107
99
108
100
resValue(" string" , " app_name" , project. ext. react. appName)
109
101
110
- def cppStd = reactNativeVersion >= v( 0 , 74 , 0 ) ? " -std=c++20" : " -std=c++17 "
102
+ def cppStd = " -std=c++20"
111
103
if (enableNewArchitecture) {
112
104
externalNativeBuild {
113
105
cmake {
114
106
arguments(" -DANDROID_STL=c++_shared" ,
115
- " -DNODE_MODULES_DIR=${ reactNativePath} /.." ,
116
107
" -DPROJECT_BUILD_DIR=${ buildDir} " ,
117
- " -DREACT_ANDROID_BUILD_DIR=${ reactNativePath} /ReactAndroid/build" ,
118
108
" -DREACT_ANDROID_DIR=${ reactNativePath} /ReactAndroid" )
119
109
cppFlags(cppStd, " -frtti" , " -fexceptions" , " -DWITH_INSPECTOR=1" )
120
110
}
@@ -142,28 +132,6 @@ android {
142
132
}
143
133
}
144
134
145
- if (! enableNewArchitecture && ! usePrefabs) {
146
- def version = getPackageVersion(" react-native" , rootDir)
147
- def allAar = file(" ${ reactNativePath} /android/com/facebook/react/react-native/${ version} /react-native-${ version} .aar" )
148
-
149
- def prepareDebugJSI = tasks. register(" prepareDebugJSI" , Copy ) {
150
- def debugAar = file(" ${ reactNativePath} /android/com/facebook/react/react-native/${ version} /react-native-${ version} -debug.aar" )
151
- from(zipTree(debugAar. exists() ? debugAar : allAar). matching({ it. include " **/libjsi.so" }))
152
- into(" ${ buildDir} /outputs/jniLibs/debug" )
153
- }
154
-
155
- def prepareReleaseJSI = tasks. register(" prepareReleaseJSI" , Copy ) {
156
- def releaseAar = file(" ${ reactNativePath} /android/com/facebook/react/react-native/${ version} /react-native-${ version} -release.aar" )
157
- from(zipTree(releaseAar. exists() ? releaseAar : allAar). matching({ it. include " **/libjsi.so" }))
158
- into(" ${ buildDir} /outputs/jniLibs/release" )
159
- }
160
-
161
- afterEvaluate {
162
- preDebugBuild. dependsOn(prepareDebugJSI)
163
- preReleaseBuild. dependsOn(prepareReleaseJSI)
164
- }
165
- }
166
-
167
135
lintOptions {
168
136
lintConfig = file(" lint.xml" )
169
137
}
@@ -198,52 +166,12 @@ android {
198
166
? " src/old-arch/java"
199
167
: reactNativeVersion >= v(0 , 81 , 0 )
200
168
? " src/new-arch-0.81/java"
201
- : reactNativeVersion >= v(0 , 73 , 0 )
202
- ? " src/new-arch-0.73/java"
203
- : " src/new-arch/java" ,
204
-
205
- // TODO: Remove this block when we drop support for 0.74
206
- // https://github.com/facebook/react-native/commit/3283202248a36dbda553745afc46a3e3e2ab41a6
207
- reactNativeVersion >= v(0 , 75 , 0 )
208
- ? " src/reactactivitydelegate-0.75/java"
209
- // TODO: Remove this block when we drop support for 0.73
210
- : reactNativeVersion >= v(0 , 74 , 0 )
211
- ? " src/reactactivitydelegate-0.74/java"
212
- // TODO: Remove this block when we drop support for 0.71
213
- // https://github.com/facebook/react-native/commit/e5dd9cdc6688e63e75a7e0bebf380be1a9a5fe2b
214
- : reactNativeVersion >= v(0 , 72 , 0 )
215
- ? " src/reactactivitydelegate-0.72/java"
216
- : " src/reactactivitydelegate-pre-0.72/java" ,
217
-
218
- // TODO: Remove this block when we drop support for 0.74
219
- // https://github.com/facebook/react-native/commit/a1e81185416a53c7c7d0cfc67e40079fd0073e7c
220
- reactNativeVersion >= v(0 , 75 , 0 )
221
- ? " src/devserverhelper-0.75/java"
222
- // TODO: Remove this block when we drop support for 0.73
223
- // https://github.com/facebook/react-native/commit/cfa02eec50469059542ccbacbc51643b525ad461
224
- : reactNativeVersion >= v(0 , 74 , 0 )
225
- ? " src/devserverhelper-0.74/java"
226
- // TODO: Remove this block when we drop support for 0.72
227
- // https://github.com/facebook/react-native/commit/da358d0ec7a492edb804b9cdce70e7516ee518ae
228
- : reactNativeVersion >= v(0 , 73 , 0 )
229
- ? " src/devserverhelper-0.73/java"
230
- : " src/devserverhelper-pre-0.73/java" ,
231
-
232
- // TODO: Remove this block when we drop support for 0.75
233
- // https://github.com/react-native-community/template/commit/f738a366b194dd21d4d2bc14c9215b630714dd70
234
- reactNativeVersion >= v(0 , 76 , 0 )
235
- ? " src/reactapplication-0.76/java"
236
- // TODO: Remove this block when we drop support for 0.72
237
- // https://github.com/facebook/react-native/commit/c3f672cef7d4f287d3d729d33650f917ed132a0c
238
- : reactNativeVersion < v(0 , 73 , 0 )
239
- ? " src/reactapplication-pre-0.73/java"
240
- : " src/reactapplication-0.73/java" ,
241
-
242
- // TODO: Remove this block when we drop support for 0.75
243
- // https://github.com/react-native-community/template/commit/f738a366b194dd21d4d2bc14c9215b630714dd70
244
- reactNativeVersion >= v(0 , 76 , 0 )
245
- ? " src/reacthost-0.76/java"
246
- : " src/reacthost-legacy/java" ,
169
+ : " src/new-arch-0.73/java" ,
170
+
171
+ " src/devserverhelper-0.75/java" ,
172
+ " src/reactactivitydelegate-0.75/java" ,
173
+ " src/reactapplication-0.76/java" ,
174
+ " src/reacthost-0.76/java" ,
247
175
]
248
176
}
249
177
@@ -260,22 +188,8 @@ android {
260
188
dependencies {
261
189
implementation project(" :support" )
262
190
263
- if (project. ext. react. enableHermes) {
264
- if (autodetectReactNativeVersion) {
265
- implementation(" com.facebook.react:hermes-android" )
266
- } else {
267
- implementation(" com.facebook.react:hermes-engine:+" ) {
268
- exclude(group : " com.facebook.fbjni" )
269
- }
270
- }
271
- }
272
-
273
- if (autodetectReactNativeVersion) {
274
- implementation(" com.facebook.react:react-android" )
275
- } else {
276
- def version = getPackageVersion(" react-native" , rootDir)
277
- implementation(" com.facebook.react:react-native:${ version} " )
278
- }
191
+ implementation(" com.facebook.react:hermes-android" )
192
+ implementation(" com.facebook.react:react-android" )
279
193
280
194
implementation(libraries. androidAppCompat)
281
195
implementation(libraries. androidCoreKotlinExtensions)
@@ -288,25 +202,10 @@ dependencies {
288
202
implementation(libraries. mlKitBarcodeScanning)
289
203
}
290
204
291
- if (reactNativeVersion == 0 || reactNativeVersion >= v(0 , 75 , 0 )) {
292
- // https://github.com/facebook/react-native/blob/b0c0bb45911434ea654ba7e2feff4686061eba7a/packages/react-native-gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt#L162
293
- def dependencies = autolinkingInfo(buildDir)
294
- dependencies. each { path , info ->
295
- info. configurations. each { configuration ->
296
- add(configuration, project(path))
297
- }
298
- }
299
- }
300
- }
301
-
302
- if (! enableNewArchitecture && ! usePrefabs) {
303
- configurations. all {
304
- resolutionStrategy {
305
- // Force version here otherwise Gradle will pick up a newer version:
306
- // https://github.com/facebook/react-native/issues/35210
307
- def version = getPackageVersion(" react-native" , rootDir)
308
- force(" com.facebook.react:react-native:${ version} " )
309
- force(" com.facebook.react:hermes-engine:${ version} " )
205
+ // https://github.com/facebook/react-native/blob/b0c0bb45911434ea654ba7e2feff4686061eba7a/packages/react-native-gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt#L162
206
+ autolinkingInfo(buildDir). each { path , info ->
207
+ info. configurations. each { configuration ->
208
+ add(configuration, project(path))
310
209
}
311
210
}
312
211
}
0 commit comments