Skip to content

Fix Android release APK crash: enable new architecture for RN 0.84#618

Open
gre wants to merge 1 commit intomasterfrom
fix/android-new-arch-turbomodule-crash
Open

Fix Android release APK crash: enable new architecture for RN 0.84#618
gre wants to merge 1 commit intomasterfrom
fix/android-new-arch-turbomodule-crash

Conversation

@gre
Copy link
Copy Markdown
Owner

@gre gre commented Mar 29, 2026

Summary

  • Enable newArchEnabled=true in gradle.properties — required for RN 0.84 which uses bridgeless/new-arch APIs in MainApplication.kt
  • Pass -PnewArchEnabled=false only for Detox Android builds (old arch compatibility)
  • Fixes TurboModuleRegistry.getEnforcing(...): 'PlatformConstants' could not be found crash on release APK

Test plan

  • CI builds pass (APK + existing jobs)
  • Release APK no longer crashes on PlatformConstants
  • Detox Android E2E still works with old arch override

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings March 29, 2026 15:45
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Enables React Native’s new architecture by default for the Android example app (required for RN 0.84’s bridgeless/new-arch initialization paths), while keeping Detox Android E2E builds on the old architecture via a Gradle property override to avoid known incompatibilities.

Changes:

  • Set newArchEnabled=true in example/android/gradle.properties.
  • Update Detox Android build command to pass -PnewArchEnabled=false when assembling APKs for E2E.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
example/android/gradle.properties Switches the example app’s default Android build to the new architecture.
example/.detoxrc.js Forces old-arch builds for Detox by overriding newArchEnabled at build time.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 32 to +35
# your application. You should enable this flag either if you want
# to write custom TurboModules/Fabric components OR use libraries that
# are providing them.
# Temporarily disabled for Detox E2E testing compatibility
newArchEnabled=false
newArchEnabled=true
Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

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

The surrounding docs still state that Android Detox runs with newArchEnabled=false set in the example app (e.g. example/e2e/README.md and CLAUDE.md). Since the default is now true and Detox is handled via a Gradle CLI override, consider updating the comment here to reflect the new behavior (and update those docs in the same PR) to avoid confusing contributors.

Copilot uses AI. Check for mistakes.
The release APK was crashing with "TurboModuleRegistry.getEnforcing(...):
'PlatformConstants' could not be found" because:

1. newArchEnabled was false while MainApplication.kt uses bridgeless APIs
   (loadReactNative, getDefaultReactHost). RN 0.84 requires new arch for
   CoreReactPackage which provides PlatformConstants.

2. The JS spec eagerly called TurboModuleRegistry.getEnforcing at module
   load time and used an outdated isTurboModuleEnabled check based on
   global.__turboModuleProxy (always true in bridgeless mode).

3. Top-level Platform.OS access in index.tsx forced eager loading of
   NativePlatformConstantsAndroid which calls getEnforcing('PlatformConstants').

Fixes:
- Enable newArchEnabled=true in gradle.properties (default for RN 0.84)
- Modernize TurboModule spec: use TurboModuleRegistry.get() instead of
  manual isTurboModuleEnabled check with getEnforcing (follows pattern
  used by react-native-safe-area-context and other maintained libraries)
- Move Platform.OS access from module top-level into validateOptions()
  to defer native module loading until first use
- Pass -PnewArchEnabled=false only for Detox Android builds

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@gre gre force-pushed the fix/android-new-arch-turbomodule-crash branch from ff3c9f1 to e16f546 Compare March 29, 2026 18:26
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.

2 participants