Skip to content

android: inject ExecOperations for Gradle 9 compatibility#386

Merged
kraenhansen merged 1 commit into
kh/adopt-static-h-node-apifrom
claude/android-gradle9-exec-operations
Jul 24, 2026
Merged

android: inject ExecOperations for Gradle 9 compatibility#386
kraenhansen merged 1 commit into
kh/adopt-static-h-node-apifrom
claude/android-gradle9-exec-operations

Conversation

@kraenhansen

Copy link
Copy Markdown
Collaborator

Targets the kh/adopt-static-h-node-api branch (PR #372).

Problem

RN 0.87 (adopted in #372) bumps the Gradle wrapper to 9.x, which removed Project.exec(). The linkNodeApiModules task in packages/host/android/build.gradle calls the bare exec {} closure inside its doLast action, so on Gradle 9 every Android build fails at configuration/execution with:

Execution failed for task ':react-native-node-api:linkNodeApiModules'.
> Could not find method exec() for arguments [...] on task ':react-native-node-api:linkNodeApiModules' of type org.gradle.api.DefaultTask.

On the #372 branch this reddened every unit-test lane (gradle.test.ts builds this module on ubuntu/macOS/windows) as well as the Test app (Android) job.

Fix

Use the Gradle 9 supported replacement: inject the ExecOperations service via an @Inject-annotated interface and call injectedExecOps.execOps.exec {} instead of the removed Project.exec().

interface InjectedExecOps {
  @Inject
  ExecOperations getExecOps()
}
def injectedExecOps = project.objects.newInstance(InjectedExecOps)

The command line, streams and environment passed to exec are unchanged.

Test plan

Native Android build isn't runnable on the CI-less Linux worker this was authored on, so the Gradle behaviour is verified by the #372 branch's CI rather than locally.


Generated by Claude Code

React Native 0.87 bumps the Gradle wrapper to 9.x, which removed
Project.exec(). The linkNodeApiModules task used the bare `exec {}` closure
in its doLast action, so every Android build (and the gradle.test.ts unit
test on all platforms) failed with:

    Could not find method exec() ... on task ':react-native-node-api:linkNodeApiModules'

Inject the ExecOperations service via an @Inject-annotated interface and call
injectedExecOps.execOps.exec {} instead, the supported Gradle 9 replacement.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TVfanKvtyfSsoMgZv3DJtY
@kraenhansen
kraenhansen merged commit 3745614 into kh/adopt-static-h-node-api Jul 24, 2026
8 of 9 checks passed
@kraenhansen
kraenhansen deleted the claude/android-gradle9-exec-operations branch July 24, 2026 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants