feat(android): Forward logs.enabled to sentry-native - #5923
Conversation
Pass `SentryOptions.Logs.isEnabled()` through to `NdkOptions` so native `sentry_log_*()` calls work when the user enables logs. Depends on getsentry/sentry-native#1971 (sentry-native-ndk release with `NdkOptions.setEnableLogs`). Fixes #5911 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Instructions and example for changelogPlease add an entry to Example: ## Unreleased
### Features
- Forward logs.enabled to sentry-native ([#5923](https://github.com/getsentry/sentry-java/pull/5923))If none of the above apply, you can opt out of this check by adding |
| ndkOptions.setEnableAppHangTracking(options.isEnableNdkAppHangTracking()); | ||
| ndkOptions.setAppHangTimeoutMillis(options.getNdkAppHangTimeoutIntervalMillis()); | ||
|
|
||
| ndkOptions.setEnableLogs(options.getLogs().isEnabled()); |
There was a problem hiding this comment.
Bug: The call to ndkOptions.setEnableLogs() will cause a NoSuchMethodError at runtime, as the method does not exist in the current sentry-native-ndk dependency version.
Severity: CRITICAL
Suggested Fix
This pull request should not be merged until the sentry-native-ndk dependency containing the NdkOptions.enableLogs field is released. After the dependency is released, update its version in gradle/libs.versions.toml before merging.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: sentry-android-ndk/src/main/java/io/sentry/android/ndk/SentryNdk.java#L79
Potential issue: The code unconditionally calls `ndkOptions.setEnableLogs()`, a method
that is part of the `sentry-native-ndk` dependency. According to the pull request
description, this feature is not yet available in the currently specified dependency
version (`0.16.2`). This will result in a `NoSuchMethodError` at runtime when
`SentryNdk.init()` is invoked. The error will cause a complete NDK initialization
failure, crashing any Android application that uses the Sentry SDK with NDK integration
during its startup sequence.
Did we get this right? 👍 / 👎 to inform future reviews.
Summary
SentryOptions.Logs.isEnabled()toNdkOptions.setEnableLogs()during NDK initsentry_log_*()/sentry_log()calls from native code on AndroidDepends on getsentry/sentry-native#1971 — needs a
sentry-native-ndkrelease with the newNdkOptions.enableLogsfield before this can merge.Fixes #5911
Test plan
sentry-native-ndkversion once the dependency PR is releasedlogs.enabled = truelogs.enabled = false(default)🤖 Generated with Claude Code