From 975f3dc991400cca4587801b5dbcf493cf5c2743 Mon Sep 17 00:00:00 2001 From: Andrew Gable Date: Tue, 25 Jun 2024 11:11:25 -0600 Subject: [PATCH] Merge pull request #44389 from software-mansion-labs/@jpiasecki/fix-failing-ci-build Fix Android builds failing often on CI (cherry picked from commit 2ef919c27bc4d01ed40e96172d1ff636e7dbb01a) --- android/app/build.gradle | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/android/app/build.gradle b/android/app/build.gradle index cb80d1db790e..6a2b2b06663a 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -190,6 +190,23 @@ android { } } +afterEvaluate { + // As the App is building from source, we need to make sure hermesc is built before the JS bundle is created. + // Otherwise the release version of the app will fail to build due to missing hermesc. + def hermesCTask = gradle.includedBuild("react-native").task(":packages:react-native:ReactAndroid:hermes-engine:buildHermesC") + + android.applicationVariants.configureEach { variant -> + if (variant.buildType.name == "release") { + def variantName = variant.name.capitalize() + def bundleTask = tasks.named("createBundle${variantName}JsAndAssets").getOrNull() + + if (bundleTask != null) { + bundleTask.dependsOn(hermesCTask) + } + } + } +} + dependencies { // The version of react-native is set by the React Native Gradle Plugin implementation("com.facebook.react:react-android")