Skip to content

build(android): Run Error Prone and NullAway on the Android modules - #6493

Merged
runningcode merged 2 commits into
mainfrom
no/errorprone-android-modules
Nov 11, 2026
Merged

runningcode merged 2 commits into
mainfrom
no/errorprone-android-modules

Conversation

@runningcode

@runningcode runningcode commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

📜 Description

Error Prone, and with it NullAway and Nopen, never ran on the Android modules.

💡 Motivation and Context

Error prone and nullaway help catch bugs!

💚 How did you test it?

CI passes

📝 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

sentry-android-ndk, sentry-android-replay and sentry-launchdarkly-android have Java sources but don't apply Error Prone at all.

Issues

🤖 Generated with Claude Code

#skip-changelog

@linear-code

linear-code Bot commented Nov 10, 2026

Copy link
Copy Markdown

JAVA-831

runningcode added a commit that referenced this pull request Nov 10, 2026
Android's default charset is always UTF-8, so DefaultCharset is
disabled for the Android modules in #6493 instead of being fixed here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
runningcode added a commit that referenced this pull request Nov 10, 2026
#6493 disables UnnecessaryLambda for the Android modules, so the
suppressions on the ANRWatchDog and AnrProfilingIntegration fields
are redundant.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@runningcode
runningcode marked this pull request as ready for review November 10, 2026 13:38
@runningcode
runningcode requested review from a team and adinauer as code owners November 10, 2026 13:39
@runningcode
runningcode requested review from 0xadam-brown and markushi and removed request for a team November 10, 2026 13:39
@runningcode runningcode added the ship-it PR is ready to merge from a reviewer perspective label Nov 10, 2026
@runningcode
runningcode changed the base branch from 9.x.x to main November 10, 2026 13:43
@runningcode
runningcode force-pushed the no/errorprone-android-modules branch from 7606835 to 73b8303 Compare November 10, 2026 13:43
runningcode added a commit that referenced this pull request Nov 11, 2026
* ref(android): Fix Error Prone warnings in sentry-android-core

Error Prone never ran on sentry-android-core. Enabling it reports 59 warnings outside Javadoc,
which fail the build under -Werror.

- Suppress FutureReturnValueIgnored, JavaUtilDate, and ReferenceEquality where identity is
  intended, as the sentry module does.
- Keep the AnrProfilingIntegration updater a field, since removeCallbacks needs the instance that
  was posted, and suppress UnnecessaryLambda there.
- Read the ANR thread dump and the app start profiling config as UTF-8, Android's default charset.
- Remove unused fields and parameters, add missing @OverRide, make long-to-double conversions
  explicit, and narrow members that are effectively private or protected in a final class.
- Explain the two catch blocks that ignore their exception.

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

* ref(android): Fix the Error Prone warnings only main has

- ANRWatchDog.monotonicTicker is never read (#6041), since the ticker lambda captures the
  constructor parameter. Remove the field and keep the parameter.
- ActivityFramesTracker.lock is protected in a final class; make it package-private.
- LifecycleWatcher reads the session start Date to seed the session window; suppress JavaUtilDate
  there, as the other Date uses are.

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

* ref(android): Keep the default charset reads as they were

Android's default charset is always UTF-8, so DefaultCharset is
disabled for the Android modules in #6493 instead of being fixed here.

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

* ref(android): Drop the UnnecessaryLambda suppressions

#6493 disables UnnecessaryLambda for the Android modules, so the
suppressions on the ANRWatchDog and AnrProfilingIntegration fields
are redundant.

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

* ref(android): Drop the updater field comment

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

* docs(android): Make the local-class method comment a plain comment

Error Prone's NotJavadoc flags Javadoc on methods of local classes, which
#6537 added in AndroidConnectionStatusProvider.

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@runningcode
runningcode force-pushed the no/errorprone-android-modules branch from 73b8303 to 0509797 Compare November 11, 2026 11:35
net.ltgt.errorprone dropped Android support in 3.0.0, which we have used since 6.7. Since then
it only enables Error Prone and adds it to the processor path for Gradle's JVM source sets. On
sentry-android-core and sentry-uitest-android the errorprone dependencies and the NullAway ERROR
setting had no effect, and the Java compile tasks ran plain javac.

Use the AGP variant API to add the errorprone configuration to each variant's annotation
processor configuration and enable Error Prone on its JavaCompile task. Both APIs exist in AGP
9.0.0, the oldest version in the AGP matrix.

Pass -XDandroidCompatible=true so Error Prone treats these modules as Android code: it skips
checks that don't apply there, such as DefaultCharset, and runs its Android checks.

sentry-uitest-android has no hand-written Java, so exclude the view binding classes AGP
generates, which trip LabelledBreakTarget.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@runningcode
runningcode force-pushed the no/errorprone-android-modules branch from 0509797 to e80ff51 Compare November 11, 2026 14:29
…vider

NullAway treats AtomicReference.get() as nullable, so the snapshot
reads added in #6537 fail once NullAway runs on sentry-android-core.
The snapshot is never set to null, so read it through one accessor
that suppresses the finding.

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

sentry Bot commented Nov 11, 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

@runningcode
runningcode merged commit cc83d6b into main Nov 11, 2026
34 checks passed
@runningcode
runningcode deleted the no/errorprone-android-modules branch November 11, 2026 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ship-it PR is ready to merge from a reviewer perspective

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error prone and noopen are not running on android modules

2 participants