@@ -186,6 +186,20 @@ android {
186
186
// preBuild.dependsOn("generateCodegenArtifactsFromSchema")
187
187
preDebugBuild. dependsOn(packageReactNdkDebugLibs)
188
188
preReleaseBuild. dependsOn(packageReactNdkReleaseLibs)
189
+
190
+ // Due to a bug inside AGP, we have to explicitly set a dependency
191
+ // between configureNdkBuild* tasks and the preBuild tasks.
192
+ // This can be removed once this is solved: https://issuetracker.google.com/issues/207403732
193
+ configureNdkBuildRelease. dependsOn(preReleaseBuild)
194
+ configureNdkBuildDebug. dependsOn(preDebugBuild)
195
+ reactNativeArchitectures(). each { architecture ->
196
+ tasks. findByName(" configureNdkBuildDebug[${ architecture} ]" )?. configure {
197
+ dependsOn(" preDebugBuild" )
198
+ }
199
+ tasks. findByName(" configureNdkBuildRelease[${ architecture} ]" )?. configure {
200
+ dependsOn(" preReleaseBuild" )
201
+ }
202
+ }
189
203
}
190
204
}
191
205
splits {
@@ -237,14 +251,8 @@ android {
237
251
dependencies {
238
252
implementation fileTree(dir : " libs" , include : [" *.jar" ])
239
253
240
- // If new architecture is enabled, we let you build RN from source
241
- // Otherwise we fallback to a prebuilt .aar bundled in the NPM package.
242
- if (isNewArchitectureEnabled()) {
243
- implementation project(" :ReactAndroid" )
244
- } else {
245
- // noinspection GradleDynamicVersion
246
- implementation " com.facebook.react:react-native:+" // From node_modules
247
- }
254
+ // noinspection GradleDynamicVersion
255
+ implementation " com.facebook.react:react-native:+" // From node_modules
248
256
249
257
implementation " androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
250
258
@@ -270,6 +278,18 @@ dependencies {
270
278
}
271
279
}
272
280
281
+ if (isNewArchitectureEnabled()) {
282
+ // If new architecture is enabled, we let you build RN from source
283
+ // Otherwise we fallback to a prebuilt .aar bundled in the NPM package.
284
+ // This will be applied to all the imported transtitive dependency.
285
+ configurations. all {
286
+ resolutionStrategy. dependencySubstitution {
287
+ substitute(module(" com.facebook.react:react-native" ))
288
+ .using(project(" :ReactAndroid" )). because(" On New Architecture we're building React Native from source" )
289
+ }
290
+ }
291
+ }
292
+
273
293
// Run this once to be able to run the application with BUCK
274
294
// puts all compile dependencies into folder libs for BUCK to use
275
295
task copyDownloadableDepsToLibs (type : Copy ) {
0 commit comments