Skip to content

feat(android): Warn when Gradle resolves unsupported sentry-android version#6238

Open
antonis wants to merge 3 commits into
mainfrom
antonislilis/rn-111-add-warning-when-gradle-resolves-to-unsupported-sentry
Open

feat(android): Warn when Gradle resolves unsupported sentry-android version#6238
antonis wants to merge 3 commits into
mainfrom
antonislilis/rn-111-add-warning-when-gradle-resolves-to-unsupported-sentry

Conversation

@antonis
Copy link
Copy Markdown
Contributor

@antonis antonis commented Jun 1, 2026

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

Adds a build-time warning when the resolved sentry-android-core version differs from what @sentry/react-native expects. The check runs in sentry.gradle.kts, which is applied in the app project's context and therefore sees the app's final resolved dependency graph.

Example warning output:

WARNING: @sentry/react-native depends on sentry-android 8.43.0, but version 8.42.0 was resolved.
This may cause build errors or unexpected behavior.
The most common cause is the Sentry Android Gradle Plugin (SAGP) overriding the version via
autoInstallation. To fix this, set autoInstallation.enabled = false in your app/build.gradle.
Other causes include resolutionStrategy.force, BOMs, or another library depending on a different
sentry-android version.

Also extracts the sentry-android version to a variable in build.gradle and updates the bump script (update-android.sh) to maintain the version in both build.gradle and sentry.gradle.kts.

💡 Motivation and Context

When @sentry/react-native is combined with SAGP (or other dependency management), Gradle may resolve sentry-android to a version different from what the RN SDK was built against. This causes cryptic build errors or runtime crashes that are hard to diagnose:

Closes RN-111

💚 How did you test it?

Tested locally against the sample app (Gradle 9.3.1 / JDK 17):

  1. Mismatch detected: Added resolutionStrategy.force 'io.sentry:sentry-android-core:8.42.0' to samples/react-native/android/app/build.gradle → warning appeared in build output.
  2. No false positive: Removed the force → no warning emitted.
  3. Bump script round-trip: update-android.sh set-version updates both build.gradle and sentry.gradle.kts correctly.
  4. yarn build passes.

📝 Checklist

  • I added tests to verify changes
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • All tests passing
  • No breaking changes

🔮 Next steps

…ersion

When the Sentry Android Gradle Plugin (SAGP) or other dependency
management overrides sentry-android to a version different from what
@sentry/react-native expects, users hit cryptic build or runtime
errors. This adds a build-time warning in sentry.gradle.kts (which
runs in the app project context) that detects the mismatch and
provides actionable guidance.

Also extracts the sentry-android version to a variable in build.gradle
and updates the bump script to maintain the version in both files.

Closes RN-111

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@linear-code
Copy link
Copy Markdown

linear-code Bot commented Jun 1, 2026

RN-111

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 1, 2026

Semver Impact of This PR

None (no version bump detected)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


  • feat(android): Warn when Gradle resolves unsupported sentry-android version by antonis in #6238
  • fix: Bump tmp to 0.2.7 to resolve path traversal vulnerability by antonis in #6233
  • feat(logs): Add enableAutoConsoleLogs option to opt out of console capture by alwx in #6235
  • chore(deps): update JavaScript SDK to v10.55.0 by github-actions in #6222
  • chore(deps): update Sentry Android Gradle Plugin to v6.9.0 by github-actions in #6230
  • refactor(android): Convert sentry.gradle to Kotlin DSL (sentry.gradle.kts) by antonis in #6119

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 1, 2026

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against f48643f

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@antonis antonis added the ready-to-merge Triggers the full CI test suite label Jun 1, 2026
@sentry
Copy link
Copy Markdown

sentry Bot commented Jun 1, 2026

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
Sentry RN io.sentry.reactnative.sample 8.13.0 (90) Release

⚙️ sentry-react-native Build Distribution Settings

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 1, 2026

Android (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 426.52 ms 473.68 ms 47.16 ms
Size 48.30 MiB 53.60 MiB 5.29 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
b9bebee+dirty 438.86 ms 452.21 ms 13.35 ms
5fe1c6c+dirty 401.62 ms 445.28 ms 43.66 ms
f3215d3+dirty 411.11 ms 454.38 ms 43.27 ms
7d6fd3a+dirty 403.02 ms 422.56 ms 19.54 ms
8929511+dirty 405.33 ms 452.16 ms 46.83 ms
eb93136+dirty 416.18 ms 467.32 ms 51.14 ms
267d3ed+dirty 413.06 ms 440.96 ms 27.90 ms
4966363+dirty 400.04 ms 431.08 ms 31.04 ms
bc0d8cf+dirty 412.37 ms 466.26 ms 53.89 ms
c151573+dirty 530.34 ms 559.43 ms 29.09 ms

App size

Revision Plain With Sentry Diff
b9bebee+dirty 48.30 MiB 53.58 MiB 5.28 MiB
5fe1c6c+dirty 43.75 MiB 48.14 MiB 4.39 MiB
f3215d3+dirty 48.30 MiB 53.49 MiB 5.19 MiB
7d6fd3a+dirty 43.75 MiB 48.14 MiB 4.39 MiB
8929511+dirty 43.75 MiB 48.16 MiB 4.41 MiB
eb93136+dirty 48.30 MiB 53.58 MiB 5.28 MiB
267d3ed+dirty 48.30 MiB 53.58 MiB 5.28 MiB
4966363+dirty 48.30 MiB 53.54 MiB 5.24 MiB
bc0d8cf+dirty 48.30 MiB 53.48 MiB 5.18 MiB
c151573+dirty 48.30 MiB 53.54 MiB 5.24 MiB

Previous results on branch: antonislilis/rn-111-add-warning-when-gradle-resolves-to-unsupported-sentry

Startup times

Revision Plain With Sentry Diff
3767c88+dirty 415.55 ms 444.85 ms 29.30 ms

App size

Revision Plain With Sentry Diff
3767c88+dirty 48.30 MiB 53.60 MiB 5.29 MiB

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 1, 2026

Android (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 415.67 ms 462.84 ms 47.17 ms
Size 48.30 MiB 53.60 MiB 5.29 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
b9bebee+dirty 500.50 ms 536.42 ms 35.92 ms
7ac3378+dirty 410.67 ms 442.60 ms 31.92 ms
8929511+dirty 469.49 ms 502.65 ms 33.16 ms
04207c4+dirty 395.40 ms 456.55 ms 61.15 ms
f3215d3+dirty 396.53 ms 436.66 ms 40.13 ms
5c1e987+dirty 444.71 ms 475.13 ms 30.42 ms
eb93136+dirty 500.37 ms 532.58 ms 32.21 ms
267d3ed+dirty 424.69 ms 483.70 ms 59.01 ms
4966363+dirty 415.67 ms 448.60 ms 32.93 ms
5fe1c6c+dirty 365.84 ms 408.62 ms 42.78 ms

App size

Revision Plain With Sentry Diff
b9bebee+dirty 48.30 MiB 53.58 MiB 5.28 MiB
7ac3378+dirty 43.94 MiB 48.99 MiB 5.05 MiB
8929511+dirty 43.94 MiB 49.02 MiB 5.08 MiB
04207c4+dirty 43.94 MiB 48.98 MiB 5.04 MiB
f3215d3+dirty 48.30 MiB 53.49 MiB 5.19 MiB
5c1e987+dirty 43.94 MiB 48.94 MiB 5.00 MiB
eb93136+dirty 48.30 MiB 53.58 MiB 5.28 MiB
267d3ed+dirty 48.30 MiB 53.58 MiB 5.28 MiB
4966363+dirty 48.30 MiB 53.54 MiB 5.24 MiB
5fe1c6c+dirty 43.94 MiB 49.00 MiB 5.06 MiB

Previous results on branch: antonislilis/rn-111-add-warning-when-gradle-resolves-to-unsupported-sentry

Startup times

Revision Plain With Sentry Diff
3767c88+dirty 465.37 ms 529.44 ms 64.06 ms

App size

Revision Plain With Sentry Diff
3767c88+dirty 48.30 MiB 53.60 MiB 5.29 MiB

@antonis antonis marked this pull request as ready for review June 1, 2026 13:18
Comment thread packages/core/android/build.gradle
Comment thread scripts/update-android.sh
- Update check-android-sdk-mismatch.js regex to parse
  sentryAndroidVersion variable instead of inline dependency string
- Add validation in update-android.sh that sentry.gradle.kts contains
  expectedSentryAndroidVersion before attempting sed replacement

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit f48643f. Configure here.

Comment thread packages/core/sentry.gradle.kts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge Triggers the full CI test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant