Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -11,6 +11,7 @@
### Features

- Add `enableAutoConsoleLogs` option to opt out of automatic `console.*` capture while keeping `enableLogs: true` for manual `Sentry.logger.*` calls ([#6235](https://github.com/getsentry/sentry-react-native/pull/6235))
- Warn when Gradle resolves `sentry-android` to a version incompatible with the SDK ([#6238](https://github.com/getsentry/sentry-react-native/pull/6238))

### Internal

Expand Down
6 changes: 4 additions & 2 deletions packages/core/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,13 @@ android {
}
}

def sentryAndroidVersion = '8.43.0'

dependencies {
compileOnly files('libs/replay-stubs.jar')
implementation 'com.facebook.react:react-native:+'
api 'io.sentry:sentry-android:8.43.0'
debugImplementation 'io.sentry:sentry-spotlight:8.43.0'
api "io.sentry:sentry-android:$sentryAndroidVersion"
Comment thread
cursor[bot] marked this conversation as resolved.
debugImplementation "io.sentry:sentry-spotlight:$sentryAndroidVersion"

testImplementation 'junit:junit:4.13.2'
testImplementation 'org.mockito:mockito-core:5.12.0'
Expand Down
34 changes: 34 additions & 0 deletions packages/core/sentry.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,43 @@ import org.codehaus.groovy.runtime.DefaultGroovyMethods
import org.gradle.api.tasks.Exec
import java.io.FileInputStream
import java.util.Properties
import java.util.concurrent.atomic.AtomicBoolean
import java.util.regex.Pattern
import javax.inject.Inject

val expectedSentryAndroidVersion = "8.43.0"

val sentryVersionCheckWarned = AtomicBoolean(false)
project.configurations.configureEach {
if (isCanBeResolved) {
incoming.afterResolve {
if (sentryVersionCheckWarned.get()) return@afterResolve
resolutionResult.allComponents {
val id = moduleVersion
if (id != null &&
id.group == "io.sentry" &&
id.name == "sentry-android-core" &&
id.version != expectedSentryAndroidVersion
Comment thread
antonis marked this conversation as resolved.
) {
if (sentryVersionCheckWarned.compareAndSet(false, true)) {
logger.warn(
"\nWARNING: @sentry/react-native depends on sentry-android " +
"$expectedSentryAndroidVersion, but version ${id.version} was resolved. " +
"This may cause build errors or unexpected behavior.\n" +
"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.\n" +
"Other causes include resolutionStrategy.force, BOMs, or another " +
"library depending on a different sentry-android version.\n" +
"See: https://docs.sentry.io/platforms/react-native/manual-setup/manual-setup/#android\n",
)
}
}
}
}
}
}

extra["shouldSentryAutoUploadNative"] =
object : groovy.lang.Closure<Boolean>(this) {
fun doCall(): Boolean = System.getenv("SENTRY_DISABLE_NATIVE_DEBUG_UPLOAD") != "true"
Expand Down
4 changes: 2 additions & 2 deletions scripts/check-android-sdk-mismatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ module.exports = async function ({ fail, warn, __, ___, danger }) {
}

const buildGradleContent = fs.readFileSync(buildGradlePath, 'utf8');
const sentryAndroidVersionMatch = buildGradleContent.match(/api\s+['"]io\.sentry:sentry-android:([^'"]+)['"]/);
const sentryAndroidVersionMatch = buildGradleContent.match(/sentryAndroidVersion\s*=\s*'([^']+)'/);

if (!sentryAndroidVersionMatch) {
warn(
createSectionWarning(
'Android SDK Version Check',
'Could not parse `sentry-android` version from build.gradle',
'Could not parse `sentryAndroidVersion` from build.gradle',
'โš ๏ธ',
),
);
Expand Down
23 changes: 14 additions & 9 deletions scripts/update-android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,33 @@ ORIGINAL_DIR=$(cd "$(dirname "$0")" && pwd)
cd $(dirname "$0")/../packages/core/android
file='build.gradle'
content=$(cat $file)
regex='(io\.sentry:sentry-android:)([0-9\.]+)'
regex="sentryAndroidVersion = '([0-9\.]+)'"
if ! [[ $content =~ $regex ]]; then
echo "Failed to find the android plugin version in $file"
echo "Failed to find the sentryAndroidVersion in $file"
exit 1
fi

case $1 in
get-version)
echo ${BASH_REMATCH[2]}
echo ${BASH_REMATCH[1]}
;;
get-repo)
echo "https://github.com/getsentry/sentry-java.git"
;;
set-version)
# Update all io.sentry dependencies to the same version
newContent="$content"
# Update sentry-android
newContent=$(echo "$newContent" | sed -E "s/(io\.sentry:sentry-android:)([0-9\.]+)/\1$2/g")
# Update sentry-spotlight
newContent=$(echo "$newContent" | sed -E "s/(io\.sentry:sentry-spotlight:)([0-9\.]+)/\1$2/g")
newContent=$(echo "$content" | sed -E "s/(sentryAndroidVersion = ')([0-9\.]+)(')/\1$2\3/g")
echo "$newContent" >$file

# Update sentry.gradle.kts version check to match
sentryGradleFile='../sentry.gradle.kts'
sentryGradleContent=$(cat $sentryGradleFile)
if ! echo "$sentryGradleContent" | grep -q 'expectedSentryAndroidVersion'; then
echo "Failed to find expectedSentryAndroidVersion in $sentryGradleFile"
exit 1
fi
sentryGradleContent=$(echo "$sentryGradleContent" | sed -E "s/(expectedSentryAndroidVersion = \")([0-9\.]+)(\")/\1$2\3/g")
echo "$sentryGradleContent" >$sentryGradleFile
Comment thread
cursor[bot] marked this conversation as resolved.

# Update expo-handler to match
expoHandlerFile='expo-handler/build.gradle'
expoHandlerContent=$(cat $expoHandlerFile)
Expand Down
Loading