Skip to content
This repository was archived by the owner on Apr 26, 2026. It is now read-only.

Commit e3e3816

Browse files
hyochanclaude
andauthored
fix(android): add CMake task dependency to prevent race condition (#3165)
## Summary - Add `afterEvaluate` block in `android/build.gradle` to ensure `buildCMake*` tasks depend on `react-native-nitro-modules`' corresponding CMake tasks - Prevents intermittent linker error where `libNitroModules.so` is not yet built when IAP's CMake runs ## Context When building with Gradle parallel execution, IAP's `buildCMakeDebug[arm64-v8a]` can run before `react-native-nitro-modules` finishes producing `libNitroModules.so`, causing a linker failure. This was a latent race condition that became more visible after the nitro-modules 0.35.0 upgrade (JNI initialization pattern change). Investigated upstream nitro 0.35.0 — no CMake/Gradle build order changes were made, confirming this is a pre-existing issue. Closes #3163 ## Test plan - [x] Android build succeeds with `--parallel` flag - [x] No regression on iOS build (android-only change, no iOS impact) 🤖 Generated with [Claude Code](https://claude.ai/code) --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 5591ae8 commit e3e3816

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

android/build.gradle

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,3 +204,20 @@ dependencies {
204204
configurations.all {
205205
exclude group: 'com.facebook.react', module: 'react-native-safe-area-context'
206206
}
207+
208+
// Ensure our CMake tasks run after react-native-nitro-modules' CMake tasks
209+
// to prevent race condition where libNitroModules.so is not yet built.
210+
// See: https://github.com/hyochan/react-native-iap/issues/3163
211+
afterEvaluate {
212+
def nitroProject = rootProject.findProject(':react-native-nitro-modules')
213+
if (nitroProject) {
214+
tasks.configureEach { task ->
215+
if (task.name.startsWith('buildCMake')) {
216+
def nitroTask = nitroProject.tasks.findByName(task.name)
217+
if (nitroTask) {
218+
task.dependsOn(nitroTask)
219+
}
220+
}
221+
}
222+
}
223+
}

0 commit comments

Comments
 (0)