diff --git a/packages/react-native/ReactAndroid/flipper-integration/src/debug/java/com/facebook/react/flipper/ReactNativeFlipper.kt b/packages/react-native/ReactAndroid/flipper-integration/src/debug/java/com/facebook/react/flipper/ReactNativeFlipper.kt index ecbef22f773105..5072cd421f3601 100644 --- a/packages/react-native/ReactAndroid/flipper-integration/src/debug/java/com/facebook/react/flipper/ReactNativeFlipper.kt +++ b/packages/react-native/ReactAndroid/flipper-integration/src/debug/java/com/facebook/react/flipper/ReactNativeFlipper.kt @@ -30,6 +30,18 @@ import com.facebook.react.modules.network.NetworkingModule object ReactNativeFlipper { @JvmStatic fun initializeFlipper(context: Context, reactInstanceManager: ReactInstanceManager) { + initializeFlipper(context, reactInstanceManager, false) + } + + @JvmStatic + fun initializeFlipper( + context: Context, + reactInstanceManager: ReactInstanceManager, + bridgelessEnabled: Boolean + ) { + if (bridgelessEnabled) { + return + } if (FlipperUtils.shouldEnableFlipper(context)) { val client = AndroidFlipperClient.getInstance(context) client.addPlugin(InspectorFlipperPlugin(context, DescriptorMapping.withDefaults())) diff --git a/packages/react-native/template/android/app/src/main/java/com/helloworld/MainApplication.kt b/packages/react-native/template/android/app/src/main/java/com/helloworld/MainApplication.kt index 77a64826ad98c7..d8a2981a644ed3 100644 --- a/packages/react-native/template/android/app/src/main/java/com/helloworld/MainApplication.kt +++ b/packages/react-native/template/android/app/src/main/java/com/helloworld/MainApplication.kt @@ -5,11 +5,16 @@ import com.facebook.react.PackageList import com.facebook.react.ReactApplication import com.facebook.react.ReactNativeHost import com.facebook.react.ReactPackage +import com.facebook.react.common.annotations.UnstableReactNativeAPI +import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.bridgelessEnabled import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load +import com.facebook.react.defaults.DefaultReactHost import com.facebook.react.defaults.DefaultReactNativeHost import com.facebook.react.flipper.ReactNativeFlipper +import com.facebook.react.interfaces.ReactHost import com.facebook.soloader.SoLoader +@UnstableReactNativeAPI class MainApplication : Application(), ReactApplication { override val reactNativeHost: ReactNativeHost = @@ -28,13 +33,26 @@ class MainApplication : Application(), ReactApplication { override val isHermesEnabled: Boolean = BuildConfig.IS_HERMES_ENABLED } + override val reactHost: ReactHost + get() = + DefaultReactHost.getDefaultReactHost( + context = this, + packageList = PackageList(this).packages, + jsMainModulePath = "index", + isHermesEnabled = BuildConfig.IS_HERMES_ENABLED) + override fun onCreate() { super.onCreate() SoLoader.init(this, false) if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) { - // If you opted-in for the New Architecture, we load the native entry point for this app. + /** + * If you opted-in for the New Architecture, we load the native entry point for this app. + * + * To enable Bridgeless you need to override "bridgelessEnabled" to true. + */ load() } - ReactNativeFlipper.initializeFlipper(this, reactNativeHost.reactInstanceManager) + ReactNativeFlipper.initializeFlipper( + this, reactNativeHost.reactInstanceManager, bridgelessEnabled) } }