Skip to content

Conversation

@markushi
Copy link
Member

📜 Description

Updates targetSdk and compileSdk to API Level 36 to support Android 16.

This PR addresses breaking changes introduced in Android 16:

  • Created ThreadUtil helper class for version-aware thread ID retrieval
  • Migrated from deprecated Thread.getId() to Thread.threadId() with backward compatibility for minSdk 21
  • Updated sample app to use OnBackPressedCallback instead of deprecated onBackPressed() which is no longer called in Android 16
  • Suppressed deprecation warning for onLowMemory() (deprecated in Android 15)

💡 Motivation and Context

Android 16 (API Level 36) deprecates several APIs that the SDK currently uses:

  • Thread.getId() is deprecated in favor of Thread.threadId() (available since API 34)
  • onBackPressed() is no longer called for apps targeting Android 16

The scheduleAtFixedRate behavior change (only executing ONE missed task instead of ALL) is acceptable and even beneficial for our performance collection use case.

💚 How did you test it?

  • Built successfully with ./gradlew spotlessApply apiDump
  • All existing tests pass
  • Verified backward compatibility with version checks

📝 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.

🔮 Next steps

  • Add to CHANGELOG.md in # Unreleased section
  • Test on Android 16 devices when available

Updates targetSdk and compileSdk to API Level 36 for Android 16 support.

Breaking changes addressed:
- Created ThreadUtil helper for version-aware thread ID retrieval
- Migrated from deprecated Thread.getId() to Thread.threadId() with backward compatibility
- Updated sample app to use OnBackPressedCallback instead of deprecated onBackPressed()

The scheduleAtFixedRate behavior change is acceptable for our performance collection use case.
@linear
Copy link

linear bot commented Jan 12, 2026

@markushi
Copy link
Member Author

@sentry review

@github-actions
Copy link
Contributor

github-actions bot commented Jan 12, 2026

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 303.08 ms 358.33 ms 55.25 ms
Size 1.58 MiB 2.19 MiB 620.06 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
dba088c 333.98 ms 381.16 ms 47.18 ms
91bb874 310.68 ms 359.24 ms 48.56 ms
d15471f 315.61 ms 360.22 ms 44.61 ms
27d7cf8 314.17 ms 347.00 ms 32.83 ms
a5ab36f 316.83 ms 394.54 ms 77.71 ms
5b66efd 308.67 ms 363.85 ms 55.18 ms
abfcc92 337.38 ms 427.39 ms 90.00 ms
fc5ccaf 279.11 ms 353.34 ms 74.23 ms
fcec2f2 328.91 ms 387.75 ms 58.84 ms
dba088c 365.46 ms 366.31 ms 0.85 ms

App size

Revision Plain With Sentry Diff
dba088c 1.58 MiB 2.13 MiB 558.99 KiB
91bb874 1.58 MiB 2.13 MiB 559.07 KiB
d15471f 1.58 MiB 2.13 MiB 559.54 KiB
27d7cf8 1.58 MiB 2.12 MiB 549.42 KiB
a5ab36f 1.58 MiB 2.12 MiB 555.26 KiB
5b66efd 1.58 MiB 2.13 MiB 559.07 KiB
abfcc92 1.58 MiB 2.13 MiB 557.31 KiB
fc5ccaf 1.58 MiB 2.13 MiB 557.54 KiB
fcec2f2 1.58 MiB 2.12 MiB 551.50 KiB
dba088c 1.58 MiB 2.13 MiB 558.99 KiB

Previous results on branch: ref/android-16-target-sdk

Startup times

Revision Plain With Sentry Diff
e036648 321.00 ms 366.07 ms 45.07 ms
5fecaf7 321.06 ms 365.79 ms 44.73 ms
8c920a7 311.40 ms 373.13 ms 61.72 ms
b51aac3 315.45 ms 345.79 ms 30.34 ms
296e3c2 327.35 ms 368.72 ms 41.37 ms

App size

Revision Plain With Sentry Diff
e036648 1.58 MiB 2.20 MiB 635.37 KiB
5fecaf7 1.58 MiB 2.19 MiB 620.06 KiB
8c920a7 1.58 MiB 2.19 MiB 620.05 KiB
b51aac3 1.58 MiB 2.20 MiB 633.90 KiB
296e3c2 1.58 MiB 2.19 MiB 620.05 KiB

@markushi
Copy link
Member Author

Retriggered the failed CI checks. The failures appear to be pre-existing flaky tests:

  1. SentryTest > if there is work enqueued, init finalizes previous session after that work is done - Flaky test unrelated to Android 16 changes
  2. corruptEnvelope UI test on API 34/35 - Element not found issue that also occurs on main branch

These failures are not related to the Android 16 targetSdk update changes in this PR.

Move getThreadId helper method from ThreadUtil into AndroidThreadChecker
to consolidate thread-related utilities. Simplify CHANGELOG entry.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@markushi
Copy link
Member Author

Addressed PR feedback:

  • Moved getThreadId() from ThreadUtil into AndroidThreadChecker
  • Deleted ThreadUtil.java
  • Simplified CHANGELOG entry to single line

All changes have been pushed in commit 4a54919.

@romtsn
Copy link
Member

romtsn commented Jan 19, 2026

the build's still failing, let me know when it's green I can check again!

@github-actions
Copy link
Contributor

github-actions bot commented Jan 19, 2026

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


Internal Changes 🔧

  • (android) Update targetSdk to API 36 (Android 16) by markushi in #5016
  • (ci) Write permission for statuses in changelog preview by supervacuus in #5053

🤖 This preview updates automatically when you update the PR.

@markushi markushi marked this pull request as ready for review January 19, 2026 14:36
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

@markushi markushi merged commit af6aa3f into main Jan 23, 2026
63 checks passed
@markushi markushi deleted the ref/android-16-target-sdk branch January 23, 2026 08:19
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.

3 participants