Android: generated ReactNativeHostManager loads React Native twice and crashes (Feature flags cannot be overridden more than once)
Los mantenedores suelen responder en 4 días
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 72/100
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
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de callstack/react-native-brownfield
-
`package:ios --add-spm-package`: allow project-declared extra XCFrameworks as binary targetsAbierto
Dificultad 4/5 3-5 días Aptitud para principiantes 55/100
callstack/react-native-brownfield#468 ·
Los mantenedores suelen responder en 4 días
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
callstack/react-native-brownfield#420 ·
Los mantenedores suelen responder en 4 días
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 38/100
callstack/react-native-brownfield#406 ·
Los mantenedores suelen responder en 4 días
-
Common network layerQuizá libre de nuevo @dratwas la tomó hace 2543 días y no hay ningún pull request abierto. Abierto
callstack/react-native-brownfield#23 · 1 asignado ·
Los mantenedores suelen responder en 4 días
-
Add support for bottom tabsQuizá libre de nuevo @krizzu la tomó hace 2543 días y no hay ningún pull request abierto. Abierto
callstack/react-native-brownfield#22 · 1 asignado ·
Los mantenedores suelen responder en 4 días
Todos los issues de callstack/react-native-brownfield
Issues similares
-
bnv-manager-v2: accept_invite creates the Mailcow domain admin before the commitPosiblemente ocupada @myOmikron la tomó hoy. Abiertobug ready-for-agent
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
-
Windows: mio 1.2.3 named-pipe use-after-free panics the native IPC broker and hangs every toolAbiertoplatform:windows tool triaged wontfix
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
nicolettas-muggelbude/RechnungsFee#448 ·
Los mantenedores suelen responder en 1 día
-
Android bug feature/error-tracking react-native team/error-tracking
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
PostHog/posthog-js#5310 · 1 comentario ·
Los mantenedores suelen responder en 1 día