Repository navigation
Conversation
AGP 9 rejects Provider instances in the SourceSet API, so applying the script failed at configuration time. On AGP 7.3+ the configuration file is now copied by a per-variant task and registered with variant.sources.assets.addGeneratedSourceDirectory. Older AGP versions keep the existing code path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
🟢 Approval recommended
No blocking issues were identified in the task implementation, variant asset registration, or legacy fallback.
No open issues 🎉
What changed in this PR
Updates the Android configuration script to support AGP 9 by registering the copied Datadog configuration as generated variant assets.
Changes:
- Adds per-variant copy tasks with declared inputs and outputs on AGP 7.3+, enabling Gradle to track configuration file changes.
- Uses the generated-assets API instead of passing a Provider to the SourceSet API.
- Preserves the existing behavior for older AGP versions.
| File | Description |
|---|---|
packages/core/datadog-configuration.gradle |
Adds version-gated copy tasks and generated asset registration while retaining the legacy fallback. |
Review effort: Balanced
There was a problem hiding this comment.
More details
The generated-assets task wiring and legacy AGP fallback appear correct based on the completed static review. Android builds were not executed, so compatibility across the claimed AGP versions remains unverified.
🤖 Bits Code Review · Commit 40f66a5
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 40f66a574b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| ) { | ||
| it.configurationFile.set(configurationFile) | ||
| } | ||
| variant.sources.assets?.addGeneratedSourceDirectory(copyTask, { it.outputDirectory }) |
There was a problem hiding this comment.
Assign an output directory before wiring the task
On every AGP 7.3+ build that applies this script, addGeneratedSourceDirectory wires the task's existing DirectoryProperty but does not choose a filesystem location for it. Because the registration block sets only configurationFile, AGP or the task action eventually queries an unset outputDirectory and the variant fails before the asset can be copied; set that property to a per-variant build directory when registering the task.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Thanks. addGeneratedSourceDirectory sets the location itself: AGP assigns the wired DirectoryProperty to build/generated/assets/<taskName>/, so no explicit value is needed. In the test builds the file lands at app/build/generated/assets/copyDatadogConfigurationFileDebug/datadog-configuration.json on AGP 7.4.2, 8.7.2 and 9.2.1, and ends up in the APK.
What does this PR do?
Makes
datadog-configuration.gradlework on Android Gradle Plugin (AGP) 9.Today, any app that applies this script (native initialization) fails to build on AGP 9:
The script adds the folder holding the copied
datadog-configuration.jsonto the app's assets by passing a lazyProvidertosrcDir, and AGP 9 no longer accepts that.With this change, on AGP 7.3 and later:
variant.sources.assets.addGeneratedSourceDirectory, which is the API AGP's error message points toOlder AGP versions keep the current code, unchanged.
Motivation
React Native 0.88 / Expo SDK 58 projects are on AGP 9, so our staging and release builds with native initialization stopped building. The only workaround is
android.sourceset.disallowProvider=false, which AGP describes as a temporary escape hatch.Side benefit: the file used to be copied while Gradle was configuring the project, not when a task ran. With the Gradle configuration cache on, an edited config file did not make it into the APK, and after cleaning the build folder the file was missing. The file is now a task input, so edits are picked up.
Additional Notes
Tested with a minimal app module, checking that
assets/datadog-configuration.jsonis in the APK:Also tested in an Expo SDK 58 app (AGP 9.2.1) without the escape hatch: the build passes, the file is in the APK, and the SDK initializes from it on an Android 15 emulator.
One visible change: on AGP 7.3+ the copy task is now per variant (
copyDatadogConfigurationFileDebug,copyDatadogConfigurationFileRelease, ...) instead of a singlecopyDatadogConfigurationFile.🤖 Generated with Claude Code