Skip to content

Expo prebuild fails unless it's a clean prebuild #5097

@justnero

Description

@justnero

What React Native libraries do you use?

Expo (mobile only)

Are you using sentry.io or on-premise?

on-premise (Self-Hosted)

@sentry/react-native SDK Version

6.20.0

How does your development environment look like?

System:
  OS: macOS 15.6
  CPU: (10) arm64 Apple M1 Max
  Memory: 498.66 MB / 64.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 22.15.0
    path: ~/.nvm/versions/node/v22.15.0/bin/node
  Yarn:
    version: 1.22.19
    path: ~/.nvm/versions/node/v22.15.0/bin/yarn
  npm:
    version: 10.9.2
    path: ~/.nvm/versions/node/v22.15.0/bin/npm
  Watchman:
    version: 2025.07.28.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.16.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.5
      - iOS 18.5
      - macOS 15.5
      - tvOS 18.5
      - visionOS 2.5
      - watchOS 11.5
  Android SDK: Not Found
IDEs:
  Android Studio: Not Found
  Xcode:
    version: 16.4/16F6
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: javac 21
    path: /Library/Java/JavaVirtualMachines/temurin-21.jdk/Contents/Home/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 20.0.1
    wanted: ^20.0.1
  react:
    installed: 19.0.0
    wanted: 19.0.0
  react-native:
    installed: 0.79.5
    wanted: 0.79.5
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: Not found
  newArchEnabled: false

Sentry.init()

Sentry.init({
  dsn: "https://...",
  sendDefaultPii: true,
  tracesSampleRate: 1,
  enableAutoPerformanceTracing: true,
  attachViewHierarchy: true,
  enableUserInteractionTracing: true,
  profilesSampleRate: 1,
  replaysSessionSampleRate: 1,
  replaysOnErrorSampleRate: 1,
  replaysSessionQuality: "low",
  attachScreenshot: true,
  integrations: [
    Sentry.mobileReplayIntegration(),
    Sentry.httpClientIntegration(),
  ],
  enableCaptureFailedRequests: true,
});

Steps to Reproduce

You should have at least one expo plugin modifying Gradle and running after Sentry plugin. For me, it was react-native-nfc-manager, might be anything else, but depends on the plugin order (with Sentry being the last one it might break in a different place).

  1. Set experimental_android.enableAndroidGradlePlugin plugin config to true
  2. Run an expo prebuild with npx expo prebuild
  3. Run an expo prebuild once more with EXPO_DEBUG=true npx expo prebuild (debug is optional, but highlights the source of issue).

Expected Result

Both prebuilds (clean and on top of existing prebuild) should complete successfully.

Actual Result

While the clean prebuild completes successfully, the second one will fail with:

› [@sentry/react-native/expo] sentry-android-gradle-plugin dependency in already in android/build.gradle.
✖ Prebuild failed
TypeError: [android.projectBuildGradle]: withAndroidProjectBuildGradleBaseMod: Cannot read properties of undefined (reading 'language')
TypeError: [android.projectBuildGradle]: withAndroidProjectBuildGradleBaseMod: Cannot read properties of undefined (reading 'language')
    at .../node_modules/@expo/config-plugins/build/android/Version.js:42:27
    at action (.../node_modules/@expo/config-plugins/build/plugins/withMod.js:199:29)
    at interceptingMod (.../node_modules/@expo/config-plugins/build/plugins/withMod.js:104:27)
    at action (.../node_modules/@expo/config-plugins/build/plugins/withMod.js:204:14)
    at async interceptingMod (.../node_modules/@expo/config-plugins/build/plugins/withMod.js:104:21)

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions