expo / sentry-expo

MIT License
202 stars 83 forks source link

[plugin] update android script injection logic #322

Closed kbrandwijk closed 1 year ago

kbrandwijk commented 1 year ago

Checklist

Why

The app/build.gradle template changed in RN 0.71, breaking the sentry script injection because the old injection point doesn't exist anymore.

How

This change opts for a safer injection point, that is backwards compatible, and matches the sentry-wizard implementation.

Test Plan

Local testing, the result is as expected, in app/build.gradle:

apply from: new File(["node", "--print", "require.resolve('@sentry/react-native/package.json')"].execute().text.trim(), "../sentry.gradle")

android {
linear[bot] commented 1 year ago
ENG-7702 sentry-expo broken for SDK 48 on Android

The previous injection point for the sentry.gradle script no longer exists in the SDK 48 app/build.gradle file, so we'll need to figure out a new anchor to inject the sentry gradle script. Relevant sentry-expo code: [https://github.com/expo/sentry-expo/blob/main/plugin/src/withSentryAndroid.ts#L44](https://github.com/expo/sentry-expo/blob/main/plugin/src/withSentryAndroid.ts#L44) SDK 47 template: [https://github.com/expo/expo/blob/sdk-47/templates/expo-template-bare-minimum/android/app/build.gradle#L92](https://github.com/expo/expo/blob/sdk-47/templates/expo-template-bare-minimum/android/app/build.gradle#L92) SDK 48 template: [https://github.com/expo/expo/blob/sdk-48/templates/expo-template-bare-minimum/android/app/build.gradle](https://github.com/expo/expo/blob/sdk-48/templates/expo-template-bare-minimum/android/app/build.gradle)