Skip to content

fix(android): Resolve NullAway findings in sentry-android-core - #6497

Draft
runningcode wants to merge 1 commit into
9.x.xfrom
no/android-core-nullaway
Draft

runningcode wants to merge 1 commit into
9.x.xfrom
no/android-core-nullaway

Conversation

@runningcode

Copy link
Copy Markdown
Contributor

📜 Description

Fixes the 32 NullAway errors in sentry-android-core. Most are nullable fields and return types without @Nullable, or null checks NullAway can't connect to the dereference because they happen in another scope (a lambda, a caller).

  • Annotates nullable fields and return types. In the sentry module, this covers the parameters of ViewHierarchyNode.setType and UiElement.equals.
  • Reads options once in lambdas, and passes scopes and options to createStandaloneAppStartTransaction, whose callers already check them.
  • Computes the device family once in DefaultAndroidEventProcessor instead of through a LazyEvaluator, whose evaluator must not return null. ContextUtils.getFamily only splits Build.MODEL.
  • Creates the system events HandlerThread in the branch that uses it, inside the existing try.

💡 Motivation and Context

NullAway is set to ERROR for sentry-android-core but never ran, because Error Prone didn't run there at all (#6493). This is one of four independent PRs that fix what it reports.

💚 How did you test it?

Compiled with Error Prone enabled: no NullAway findings remain and none are added. The unit tests of the touched classes pass.

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.

🔮 Next steps

ViewHierarchyEventProcessor.snapshotViewHierarchyAsData is now @Nullable. It already returned null when the hierarchy couldn't be captured. Kotlin callers in hybrid SDKs now see ByteArray? and have to handle null.

🤖 Generated with Claude Code

#skip-changelog

NullAway never ran on sentry-android-core. Enabling it reports 32 errors. Most are fields and
return types that are nullable but not annotated, and fields NullAway cannot see as checked
because a check happens in a different scope (a lambda, another method) than the dereference.

- Annotate the nullable fields and return types, including ViewHierarchyNode.setType and
  UiElement.equals in the sentry module.
- Read options once in lambdas, and pass scopes and options to
  createStandaloneAppStartTransaction, whose callers already check them.
- Compute the device family once instead of through a LazyEvaluator, whose evaluator must not
  return null.
- Create the system events HandlerThread in the branch that uses it, inside the existing try.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sentry

sentry Bot commented Nov 6, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.63.0 (1) release

⚙️ sentry-android Build Distribution Settings

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant