Skip to content

Commit a0ff8e7

Browse files
antonisclaude
andauthored
docs(react-native): Add warning about AGP autoInstallation on Android (#17349)
## DESCRIBE YOUR PR Add documentation warning that the Sentry Android Gradle Plugin `autoInstallation` must be disabled when using React Native, to prevent `IllegalStateException: Sentry SDK has detected a mix of versions` crashes. - Add warning alert to manual setup guide about `autoInstallation` needing to be `false` - Add warning alert to v7-to-v8 migration guide - Add troubleshooting section for the `IllegalStateException` mix of versions crash with solution and link to GitHub issue Refs getsentry/sentry-react-native#5682 ## IS YOUR CHANGE URGENT? Help us prioritize incoming PRs by letting us know when the change needs to go live. - [ ] Urgent deadline (GA date, etc.): - [ ] Other deadline: - [x] None: Not urgent, can wait up to 1 week+ ## SLA - Teamwork makes the dream work, so please add a reviewer to your PRs. - Please give the docs team up to 1 week to review your PR unless you've added an urgent due date to it. Thanks in advance for your help! ## PRE-MERGE CHECKLIST *Make sure you've checked the following before merging your changes:* - [ ] Checked Vercel preview for correctness, including links - [ ] PR was reviewed and approved by any necessary SMEs (subject matter experts) - [ ] PR was reviewed and approved by a member of the [Sentry docs team](https://github.com/orgs/getsentry/teams/docs) --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 2208fe0 commit a0ff8e7

3 files changed

Lines changed: 40 additions & 1 deletion

File tree

docs/platforms/react-native/manual-setup/manual-setup.mdx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,12 @@ buildscript {
185185

186186
You can configure the plugin options in `android/app/build.gradle`, as shown below:
187187

188+
<Alert level="warning" title="Auto-Installation Must Be Disabled">
189+
190+
The `autoInstallation` option **must** be set to `false` when using the Sentry Android Gradle Plugin with React Native. The `@sentry/react-native` SDK manages its own `sentry-android` dependency. If auto-installation is enabled, the plugin may pull in a different `sentry-android` version, causing an `IllegalStateException: Sentry SDK has detected a mix of versions` crash at app startup.
191+
192+
</Alert>
193+
188194
```groovy {filename:android/app/build.gradle}
189195
apply plugin: "io.sentry.android.gradle"
190196
@@ -207,6 +213,7 @@ sentry {
207213
// which might be incompatible with the React Native SDK
208214
// Enable auto-installation of Sentry components (sentry-android SDK and okhttp, timber and fragment integrations).
209215
// Default is enabled.
216+
// IMPORTANT: Must be false for React Native.
210217
autoInstallation {
211218
enabled = false
212219
}

docs/platforms/react-native/migration/v7-to-v8.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ buildscript {
6161
}
6262
```
6363

64+
<Alert level="warning" title="Sentry Android Gradle Plugin Auto-Installation">
65+
66+
If you use the Sentry Android Gradle Plugin (AGP), make sure `autoInstallation` is **disabled** in your `android/app/build.gradle`. The `@sentry/react-native` SDK ships with its own compatible `sentry-android` dependency. If `autoInstallation` is enabled, the plugin may pull in a different `sentry-android` version, causing an `IllegalStateException: Sentry SDK has detected a mix of versions` crash at app startup. See the [manual setup guide](/platforms/react-native/manual-setup/manual-setup/#enable-sentry-agp) for the correct configuration.
67+
68+
</Alert>
69+
6470
#### Sentry Self-Hosted
6571

6672
Sentry CLI v3 requires self-hosted Sentry instances version **25.11.1+** (previously 25.2.0).

docs/platforms/react-native/troubleshooting/index.mdx

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ When you remove the environmental variable in front of your build command, your
308308

309309
## Expo Transactions Never Finish
310310

311-
If you're using [expo-dev-client](https://docs.expo.dev/development/introduction/#what-is-an-expo-dev-client), you might notice that transactions never finish in your dev builds. This is due to logs that the dev client is continuously sending to the development server. To fix this, you can stop creating spans for the HTTP requests to the log endpoint in your dev builds by adding the following to your `Sentry.init()`:
311+
If you're using [expo-dev-client](https://docs.expo.dev/develop/development-builds/introduction/), you might notice that transactions never finish in your dev builds. This is due to logs that the dev client is continuously sending to the development server. To fix this, you can stop creating spans for the HTTP requests to the log endpoint in your dev builds by adding the following to your `Sentry.init()`:
312312

313313
```javascript
314314
import * as Sentry from "sentry-expo";
@@ -359,6 +359,32 @@ You can also use [Advanced Data Scrubbing](/security-legal-pii/scrubbing/advance
359359
[Replace] [Anything] from [contexts.trace.data.previousRoute.params]
360360
```
361361
362+
## Android: IllegalStateException Mix of Versions
363+
364+
If your Android app crashes on startup with:
365+
366+
```
367+
IllegalStateException: Sentry SDK has detected a mix of versions
368+
```
369+
370+
This is caused by the Sentry Android Gradle Plugin (AGP) auto-installing a `sentry-android` version that conflicts with the one shipped by `@sentry/react-native`.
371+
372+
### Solution
373+
374+
Set `autoInstallation.enabled = false` in your `android/app/build.gradle`:
375+
376+
```groovy {filename:android/app/build.gradle}
377+
sentry {
378+
autoInstallation {
379+
enabled = false
380+
}
381+
}
382+
```
383+
384+
The React Native SDK manages its own compatible `sentry-android` dependency, so the Gradle plugin should not auto-install one. See the [manual setup guide](/platforms/react-native/manual-setup/manual-setup/#enable-sentry-agp) for the full configuration.
385+
386+
For more information, see [GitHub issue #5682](https://github.com/getsentry/sentry-react-native/issues/5682).
387+
362388
## Sentry Android Gradle Plugin Circular Dependency
363389
364390
If you encounter a circular dependency error when building your Android app with the Sentry Android Gradle Plugin, this is typically caused by using an older version of the Android Gradle Plugin (AGP).

0 commit comments

Comments
 (0)