Skip to content

Conversation

@antonis
Copy link
Contributor

@antonis antonis commented Jan 29, 2026

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

Replaces separate build-android-debug-auto.sh and build-android-debug-manual.sh scripts with a single consolidated build-android-debug-init.sh that validates SENTRY_DISABLE_NATIVE_START and provides clear error messages.

Key improvements:

  • Single source of truth for Android build logic
  • Environment variable validation with helpful error messages
  • Maps true/false to auto/manual build modes
  • Dynamic APK naming based on mode
  • Error handling if APK not found

Package.json now calls the script directly with the env var inline, eliminating the need for wrapper scripts while maintaining the same developer ergonomics (yarn build-android-debug-auto/manual still work).

💡 Motivation and Context

See #5583 (comment)

💚 How did you test it?

CI

📝 Checklist

  • I added tests to verify 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.
  • All tests passing
  • No breaking changes

🔮 Next steps

#skip-changelog

krystofwoldrich and others added 30 commits January 21, 2025 17:22
…ructures (#4445)

* Extract Android SDK Init

* Update tests

* Adds changelog

* Fix lint issues

* Rename RNSentryStart instance for clarity

* Converts RNSentryStart to utility class

* Update CHANGELOG.md

---------

Co-authored-by: Krystof Woldrich <31292499+krystofwoldrich@users.noreply.github.com>
* Convert json object to writable map

* Make class/methods package-private(default)
- Resolved merge conflicts across iOS, Android, and JavaScript/TypeScript code
- Updated iOS implementation to use RNSentryStart API
- Fixed Android compilation errors for Sentry Android SDK v7 compatibility
- Removed deprecated API calls (setEnableTracing, getPackages, getIntegrations)
- Updated Gradle build scripts and resolved conflict markers
- All builds verified: iOS, Android, and Expo sample apps compile successfully
antonis and others added 8 commits January 27, 2026 15:23
* fix(android): Fix ConcurrentModificationException when disabling native crash handling

When enableNativeCrashHandling is set to false, the code was iterating over
the integrations list with a for-each loop while calling remove() directly,
which causes a ConcurrentModificationException at runtime.

Fixed by using Java 8's removeIf() method which safely handles iteration
and removal in a single operation. This is more concise and follows modern
Java best practices.

Added unit tests to verify the fix and ensure integrations are properly
removed without throwing exceptions.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* Lint fix

---------

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
…carUrl

The code attempted to read defaultSidecarUrl without checking if the key
exists in the options map. This caused a NoSuchKeyException crash during
startup when spotlight was set to true in sentry.options.json without
providing defaultSidecarUrl.

Added key existence check to match iOS implementation behavior and prevent
the crash while maintaining backward compatibility.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Replaces separate build-android-debug-auto.sh and build-android-debug-manual.sh
scripts with a single consolidated build-android-debug-init.sh that validates
SENTRY_DISABLE_NATIVE_START and provides clear error messages.

Key improvements:
- Single source of truth for Android build logic
- Environment variable validation with helpful error messages
- Maps true/false to auto/manual build modes
- Dynamic APK naming based on mode
- Error handling if APK not found

Package.json now calls the script directly with the env var inline,
eliminating the need for wrapper scripts while maintaining the same
developer ergonomics (yarn build-android-debug-auto/manual still work).

Addresses review feedback from lucas-zimerman at:
#5583 (comment)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@github-actions
Copy link
Contributor

github-actions bot commented Jan 29, 2026

Semver Impact of This PR

None (no version bump detected)

📋 Changelog Preview

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


This PR will not appear in the changelog.


🤖 This preview updates automatically when you update the PR.

* test(e2e): Add auto init from JS tests for Android

Implements Android E2E testing infrastructure to verify both manual native initialization and auto initialization from JavaScript, matching the iOS implementation and resolving issue #4912.

Key additions:
- Jest configs for android.auto and android.manual test modes
- Build scripts that toggle SENTRY_DISABLE_NATIVE_START at compile time
- Test scripts to run auto and manual test suites separately
- App start crash testing via flag file mechanism
- TestControlModule to enable/disable crash-on-start from JS
- Comprehensive E2E test documentation

Unlike iOS which uses launch arguments at runtime, Android requires separate builds with different build configurations to control native initialization.

Closes #4912

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* fix(e2e): Add scrolling to find crash control buttons in Android test

The crash control buttons are off-screen, so the Maestro flow needs to
scroll to find them before tapping. This matches the pattern used in
other Android E2E tests.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* fix(e2e): Make Android crash flag auto-expire after one crash

The crash flag file was persisting across app launches, causing the app
to crash indefinitely. Now the flag auto-deletes when read, allowing:
1. First launch: Enable flag
2. Second launch: Read flag, delete it, then crash
3. Third launch: Start normally and send crash report

This solves the chicken-and-egg problem where the app couldn't reach
JavaScript to clear the flag because it kept crashing before JS loaded.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* fix(e2e): Handle wrapped exceptions in Android crash test

Android wraps exceptions thrown in Application.onCreate() with:
"Unable to create application... RuntimeException: <original message>"

Updated the test to check if ANY exception in the chain contains our
intentional crash message, rather than expecting an exact match on the
first exception.

Test now passes locally and should pass in CI.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* Clean up notes for now

---------

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
Base automatically changed from antonis/test-capture-app-start-errors-android to antonis/capture-app-start-errors-v8 January 29, 2026 13:23
@antonis antonis added the ready-to-merge Triggers the full CI test suite label Jan 29, 2026
# Conflicts:
#	samples/react-native/android/app/build.gradle
@github-actions
Copy link
Contributor

github-actions bot commented Jan 29, 2026

Android (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 440.22 ms 486.44 ms 46.22 ms
Size 43.94 MiB 49.26 MiB 5.33 MiB

Baseline results on branch: v8

Startup times

Revision Plain With Sentry Diff
b4fa5b4+dirty 382.09 ms 398.28 ms 16.19 ms
12fba4a+dirty 456.57 ms 462.90 ms 6.32 ms
fa0d109+dirty 413.71 ms 434.22 ms 20.51 ms
d6aa223+dirty 436.98 ms 466.42 ms 29.44 ms
206e87e+dirty 416.94 ms 440.98 ms 24.04 ms
bc8a1ed+dirty 396.10 ms 426.80 ms 30.69 ms

App size

Revision Plain With Sentry Diff
b4fa5b4+dirty 43.94 MiB 48.91 MiB 4.97 MiB
12fba4a+dirty 43.94 MiB 49.22 MiB 5.29 MiB
fa0d109+dirty 43.94 MiB 49.22 MiB 5.29 MiB
d6aa223+dirty 43.94 MiB 49.38 MiB 5.44 MiB
206e87e+dirty 43.94 MiB 49.22 MiB 5.29 MiB
bc8a1ed+dirty 43.94 MiB 48.91 MiB 4.97 MiB

antonis and others added 2 commits January 29, 2026 14:48
…ions

Fixes a crash on Android startup when initializing from sentry.options.json
without dsn or devServerUrl fields. The code was calling getString() on
ReadableMap without checking if the keys exist first, which throws
NoSuchKeyException for missing keys.

Both fields are optional in configuration files, so the code now checks
for key existence before accessing values, returning null when keys are
missing. This matches the pattern used throughout the rest of the file
and is already handled correctly by the null-checks in the breadcrumb
filter logic.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Base automatically changed from antonis/capture-app-start-errors-v8 to v8 January 29, 2026 15:26
@antonis antonis marked this pull request as ready for review January 29, 2026 16:16
@github-actions
Copy link
Contributor

github-actions bot commented Jan 29, 2026

Android (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 413.51 ms 443.87 ms 30.36 ms
Size 43.75 MiB 48.40 MiB 4.65 MiB

Baseline results on branch: v8

Startup times

Revision Plain With Sentry Diff
b4fa5b4+dirty 449.55 ms 481.50 ms 31.95 ms
12fba4a+dirty 483.60 ms 514.49 ms 30.89 ms
fa0d109+dirty 429.60 ms 452.50 ms 22.90 ms
d6aa223+dirty 543.40 ms 564.24 ms 20.84 ms
206e87e+dirty 464.80 ms 504.68 ms 39.88 ms
bc8a1ed+dirty 442.18 ms 476.27 ms 34.08 ms

App size

Revision Plain With Sentry Diff
b4fa5b4+dirty 43.75 MiB 48.08 MiB 4.33 MiB
12fba4a+dirty 43.75 MiB 48.40 MiB 4.64 MiB
fa0d109+dirty 43.75 MiB 48.40 MiB 4.64 MiB
d6aa223+dirty 43.75 MiB 48.55 MiB 4.80 MiB
206e87e+dirty 43.75 MiB 48.40 MiB 4.64 MiB
bc8a1ed+dirty 43.75 MiB 48.08 MiB 4.33 MiB

@github-actions
Copy link
Contributor

github-actions bot commented Jan 29, 2026

iOS (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1216.88 ms 1222.51 ms 5.63 ms
Size 3.38 MiB 4.68 MiB 1.30 MiB

Baseline results on branch: v8

Startup times

Revision Plain With Sentry Diff
206e87e+dirty 1184.11 ms 1183.19 ms -0.92 ms
b4fa5b4+dirty 1203.83 ms 1207.13 ms 3.30 ms
d6aa223+dirty 1192.33 ms 1208.17 ms 15.84 ms
12fba4a+dirty 1214.20 ms 1223.30 ms 9.09 ms
bc8a1ed+dirty 1194.70 ms 1201.18 ms 6.48 ms
fa0d109+dirty 1216.02 ms 1220.67 ms 4.65 ms

App size

Revision Plain With Sentry Diff
206e87e+dirty 3.38 MiB 4.67 MiB 1.29 MiB
b4fa5b4+dirty 3.44 MiB 4.66 MiB 1.22 MiB
d6aa223+dirty 3.38 MiB 4.67 MiB 1.29 MiB
12fba4a+dirty 3.38 MiB 4.67 MiB 1.29 MiB
bc8a1ed+dirty 3.44 MiB 4.66 MiB 1.22 MiB
fa0d109+dirty 3.38 MiB 4.67 MiB 1.29 MiB

@github-actions
Copy link
Contributor

github-actions bot commented Jan 29, 2026

iOS (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1201.31 ms 1205.76 ms 4.45 ms
Size 3.38 MiB 4.68 MiB 1.30 MiB

Baseline results on branch: v8

Startup times

Revision Plain With Sentry Diff
206e87e+dirty 1197.12 ms 1204.25 ms 7.13 ms
b4fa5b4+dirty 1213.59 ms 1211.26 ms -2.33 ms
d6aa223+dirty 1216.76 ms 1213.40 ms -3.37 ms
12fba4a+dirty 1209.43 ms 1217.08 ms 7.65 ms
bc8a1ed+dirty 1198.66 ms 1200.60 ms 1.94 ms
fa0d109+dirty 1206.81 ms 1205.38 ms -1.43 ms

App size

Revision Plain With Sentry Diff
206e87e+dirty 3.38 MiB 4.67 MiB 1.29 MiB
b4fa5b4+dirty 3.44 MiB 4.66 MiB 1.22 MiB
d6aa223+dirty 3.38 MiB 4.67 MiB 1.29 MiB
12fba4a+dirty 3.38 MiB 4.67 MiB 1.29 MiB
bc8a1ed+dirty 3.44 MiB 4.66 MiB 1.22 MiB
fa0d109+dirty 3.38 MiB 4.67 MiB 1.29 MiB

The Gradle daemon uses System.getenv() to read SENTRY_DISABLE_NATIVE_START
and set BuildConfig.SENTRY_DISABLE_NATIVE_START. Without exporting the
variable, the daemon may use stale values from its environment or fall back
to the gradle.properties default (false), causing builds to use incorrect
Sentry initialization modes.

This fix ensures the variable is properly exported before calling the build
script, guaranteeing the Gradle daemon receives the correct value and builds
APKs with the intended initialization mode (auto vs manual).

Without this fix:
- yarn build-android-debug-auto could build with native init enabled
- E2E tests would fail due to incorrect APK configuration

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

antonis commented Jan 30, 2026

@sentry review

Copy link
Contributor Author

@antonis antonis left a comment

Choose a reason for hiding this comment

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

Noting that the End-to-End Tests V2 / Test RN 0.83.0 legacy hermes ios production no and End-to-End Tests V2 / Test RN 0.83.0 new hermes ios production no (push) captureReplay tests are is also occurring on main and will be investigated separately

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

Labels

ready-to-merge Triggers the full CI test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants