@@ -17,25 +17,19 @@ buildDir = "${rootDir}/${name}/build"
1717
1818def  reactNativePath =  file(findNodeModulesPath(" react-native" 
1919
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" 
28-                 : findNodeModulesPath(" react-native-codegen" 
29-         )
30-     }
20+ apply(plugin : " com.facebook.react" 
3121
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" 
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 
3933    }
4034}
4135
@@ -78,10 +72,8 @@ android {
7872        ndkVersion =  project. ext. ndkVersion
7973    }
8074
81-     if  (usePrefabs) {
82-         buildFeatures {
83-             prefab =  true 
84-         }
75+     buildFeatures {
76+         prefab =  true 
8577    }
8678
8779    kotlinOptions {
@@ -107,7 +99,6 @@ android {
10799
108100        resValue(" string" " app_name" . ext. react. appName)
109101
110-         def  cppStd =  reactNativeVersion >=  v(0 , 74 , 0 ) ?  " -std=c++20" :  " -std=c++17" 
111102        if  (enableNewArchitecture) {
112103            externalNativeBuild {
113104                cmake {
@@ -116,7 +107,7 @@ android {
116107                              " -DPROJECT_BUILD_DIR=${ buildDir} " 
117108                              " -DREACT_ANDROID_BUILD_DIR=${ reactNativePath} " 
118109                              " -DREACT_ANDROID_DIR=${ reactNativePath} " 
119-                     cppFlags(cppStd , " -frtti" " -fexceptions" " -DWITH_INSPECTOR=1" 
110+                     cppFlags(" -std=c++20 " " -frtti" " -fexceptions" " -DWITH_INSPECTOR=1" 
120111                }
121112            }
122113            if  (! project. ext. react. abiSplit) {
@@ -142,28 +133,6 @@ android {
142133        }
143134    }
144135
145-     if  (! enableNewArchitecture &&  ! usePrefabs) {
146-         def  version =  getPackageVersion(" react-native" 
147-         def  allAar =  file(" ${ reactNativePath} ${ version} ${ version} " 
148- 
149-         def  prepareDebugJSI =  tasks. register(" prepareDebugJSI" Copy ) {
150-             def  debugAar =  file(" ${ reactNativePath} ${ version} ${ version} " 
151-             from(zipTree(debugAar. exists() ?  debugAar :  allAar). matching({ it. include " **/libjsi.so" 
152-             into(" ${ buildDir} " 
153-         }
154- 
155-         def  prepareReleaseJSI =  tasks. register(" prepareReleaseJSI" Copy ) {
156-             def  releaseAar =  file(" ${ reactNativePath} ${ version} ${ version} " 
157-             from(zipTree(releaseAar. exists() ?  releaseAar :  allAar). matching({ it. include " **/libjsi.so" 
158-             into(" ${ buildDir} " 
159-         }
160- 
161-         afterEvaluate {
162-             preDebugBuild. dependsOn(prepareDebugJSI)
163-             preReleaseBuild. dependsOn(prepareReleaseJSI)
164-         }
165-     }
166- 
167136    lintOptions {
168137        lintConfig =  file(" lint.xml" 
169138    }
@@ -198,46 +167,11 @@ android {
198167                ?  " src/old-arch/java" 
199168                : reactNativeVersion >=  v(0 , 81 , 0 )
200169                    ?  " 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" 
170+                     : " src/new-arch-0.73/java" 
171+ 
172+             " src/devserverhelper-0.75/java" 
173+             " src/reactactivitydelegate-0.75/java" 
174+             " src/reactapplication-0.76/java" 
241175        ]
242176    }
243177
@@ -254,22 +188,8 @@ android {
254188dependencies  {
255189    implementation project(" :support" 
256190
257-     if  (project. ext. react. enableHermes) {
258-         if  (autodetectReactNativeVersion) {
259-             implementation(" com.facebook.react:hermes-android" 
260-         } else  {
261-             implementation(" com.facebook.react:hermes-engine:+" 
262-                 exclude(group : " com.facebook.fbjni" 
263-             }
264-         }
265-     }
266- 
267-     if  (autodetectReactNativeVersion) {
268-         implementation(" com.facebook.react:react-android" 
269-     } else  {
270-         def  version =  getPackageVersion(" react-native" 
271-         implementation(" com.facebook.react:react-native:${ version} " 
272-     }
191+     implementation(" com.facebook.react:hermes-android" 
192+     implementation(" com.facebook.react:react-android" 
273193
274194    implementation(libraries. androidAppCompat)
275195    implementation(libraries. androidCoreKotlinExtensions)
@@ -282,25 +202,11 @@ dependencies {
282202        implementation(libraries. mlKitBarcodeScanning)
283203    }
284204
285-     if  (reactNativeVersion ==  0  ||  reactNativeVersion >=  v(0 , 75 , 0 )) {
286-         //  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
287-         def  dependencies =  autolinkingInfo(buildDir)
288-         dependencies. each { path , info  -> 
289-             info. configurations. each { configuration  -> 
290-                 add(configuration, project(path))
291-             }
292-         }
293-     }
294- }
295- 
296- if  (! enableNewArchitecture &&  ! usePrefabs) {
297-     configurations. all {
298-         resolutionStrategy {
299-             //  Force version here otherwise Gradle will pick up a newer version:
300-             //  https://github.com/facebook/react-native/issues/35210
301-             def  version =  getPackageVersion(" react-native" 
302-             force(" com.facebook.react:react-native:${ version} " 
303-             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+     def  dependencies =  autolinkingInfo(buildDir)
207+     dependencies. each { path , info  -> 
208+         info. configurations. each { configuration  -> 
209+             add(configuration, project(path))
304210        }
305211    }
306212}
0 commit comments