Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

### Fixes

- Fix AGP Artifacts API conflict caused by eager task realization in `sentry.gradle` ([#5714](https://github.com/getsentry/sentry-react-native/pull/5714))
- Fix Android crash on app launch caused by version mismatch between Sentry Android SDK and Sentry Android Gradle Plugin ([#5726](https://github.com/getsentry/sentry-react-native/pull/5726))

### Dependencies
Expand Down
18 changes: 13 additions & 5 deletions packages/core/sentry.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,19 @@ plugins.withId('com.android.application') {

androidComponents.onVariants(androidComponents.selector().all()) { v ->
if (!v.name.toLowerCase().contains("debug")) {
// separately we then hook into the bundle task of react native to inject
// sourcemap generation parameters. In case for whatever reason no release
// was found for the asset folder we just bail.
def bundleTasks = tasks.findAll { task -> (task.name.startsWith("createBundle") || task.name.startsWith("bundle")) && task.name.endsWith("JsAndAssets") && !task.name.contains("Debug") && task.enabled }
bundleTasks.each { bundleTask ->
// Hook into the bundle task of react native to inject sourcemap generation parameters.
// tasks.names.contains() checks task existence without iterating the container, avoiding
// eager realization of unrelated tasks (fixes #5698, Fullstory AGP Artifacts API).
def variantCapitalized = v.name.capitalize()
def sentryBundleTaskName = ["createBundle${variantCapitalized}JsAndAssets", "bundle${variantCapitalized}JsAndAssets"].find { tasks.names.contains(it) }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

theoretically we could use this named overload which accepts a string filter? It would return a TaskCollection which we could run a forEach or configureEach on, preserving the previous behavior pretty much.

But no strong preference, the current approach is also fine!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for looking at this @romtsn ๐Ÿ™‡
I think this is a good suggestion. I'll keep this PR as is for now since it has been tested to fix the issue and ship it with 8.2.0 later today. I'll iterate on the suggestion on a follow up PR.

if (sentryBundleTaskName == null) {
project.logger.warn("[sentry] No bundle task found for variant '${v.name}'. " +
"Expected 'createBundle${variantCapitalized}JsAndAssets' or " +
"'bundle${variantCapitalized}JsAndAssets'. Source maps will not be uploaded.")
return
}
def bundleTask = tasks.named(sentryBundleTaskName).get()
if (bundleTask.enabled) {
def shouldCleanUp
def sourcemapOutput
def bundleOutput
Expand Down
Loading