Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Android: generated ReactNativeHostManager loads React Native twice and crashes (Feature flags cannot be overridden more than once)

Abierto Apto para principiantes
#492 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 4 días

@hurali97 ya está trabajando en esto.

Desde el 16/10/2026.

  • #500 de @hurali97 — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
72/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
android, kotlin, react-native
Área
mobile

Línea de trabajo

Empieza con la plantilla generada ReactNativeHostManager.vanilla.kt en la carpeta de plantillas de expo-config-plugin, y compárala con ReactNativeBrownfield.kt, donde initialize llama a loadNativeLibs (SoLoader.init y DefaultNewArchitectureEntryPoint.load). Reproduce el problema generando un proyecto e iniciando la app. Está terminado cuando la plantilla ya no llama a loadReactNative(application) y la app se inicia sin el error de feature flag.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

The ReactNativeHostManager.kt that npm create @callstack/react-native-brownfield generates for a React Native CLI project crashes when the native app starts React Native:

java.lang.RuntimeException: Feature flags cannot be overridden more than once
  at com.facebook.react.internal.featureflags.ReactNativeFeatureFlags.override(ReactNativeFeatureFlags.kt:558)
  at com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load(DefaultNewArchitectureEntryPoint.kt:101)
  at com.callstack.reactnativebrownfield.ReactNativeBrownfield$Companion.loadNativeLibsInternal(ReactNativeBrownfield.kt:49)
  at com.callstack.reactnativebrownfield.ReactNativeBrownfield$Companion.initialize(ReactNativeBrownfield.kt:66)
  at com.rnapp.ReactNativeHostManager.initialize(ReactNativeHostManager.kt:28)

Cause: the template (ReactNativeHostManager.vanilla.kt) calls loadReactNative(application) and then ReactNativeBrownfield.initialize(application, reactHost, ...). Both run DefaultNewArchitectureEntryPoint.load(), which sets React Native's feature flags, so the second call throws. The nativeLibsLoaded guard in ReactNativeBrownfield.kt can't see the earlier loadReactNative call.

Repro: https://github.com/gronxb/react-native-brownfield-492-repro. It has the scaffold output and a minimal native Android app that starts React Native from a button. The README has the steps, and the comment below has videos of the crash and the fix.

Fix: remove loadReactNative(application) and pass the React host as a factory, as the Expo template (ReactNativeHostManager.post55.kt) already does:

ReactNativeBrownfield.initialize(application, onJSBundleLoaded) {
    getDefaultReactHost(
        context = application,
        packageList = PackageList(application).packages,
        jsMainModulePath = "index",
        jsBundleAssetPath = "index.android.bundle",
        jsBundleFilePath = null,
        useDevSupport = BuildConfig.DEBUG,
        jsRuntimeFactory = null
    )
}

Removing only loadReactNative is not enough. The template builds the host (val reactHost by lazy { getDefaultReactHost(...) }) as an argument to the deprecated initialize(application, reactHost, ...) overload, so it is built before initialize loads the native libraries, and the app then fails with SoLoader.init() not yet called. loadReactNative also turns on edge-to-edge when IS_EDGE_TO_EDGE_ENABLED is set, so a template fix should keep that part.

Tested with: @callstack/create-react-native-brownfield 5.3.0, @callstack/react-native-brownfield 5.3.0, React Native 0.85.2, Android emulator (API 37).

Edited: the first version of this issue suggested removing only loadReactNative, which isn't enough, as explained above.

Lenguaje dominante
TypeScript
Estrellas
552
Forks
53
Merge medio
4 d 13 h
PR fusionados (30 d)
15

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de callstack/react-native-brownfield

Todos los issues de callstack/react-native-brownfield

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.