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")