Android: generated ReactNativeHostManager loads React Native twice and crashes (Feature flags cannot be overridden more than once)
Les mainteneurs répondent en général sous 4 jours
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Accessibilité débutants
- 72/100
Piste de recherche
Commence par le modèle généré ReactNativeHostManager.vanilla.kt dans le dossier de templates du expo-config-plugin, puis compare-le à ReactNativeBrownfield.kt, où initialize appelle loadNativeLibs (SoLoader.init et DefaultNewArchitectureEntryPoint.load). Reproduis le problème en générant un projet et en lançant l'application. C'est terminé lorsque le modèle n'appelle plus loadReactNative(application) et que l'application démarre sans l'erreur liée aux feature flags.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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.
- Langage dominant
- TypeScript
- Étoiles
- 552
- Forks
- 53
- Merge moyen
- 4 j 13 h
- PR mergées (30 j)
- 15
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de callstack/react-native-brownfield
-
`package:ios --add-spm-package`: allow project-declared extra XCFrameworks as binary targetsOuverte
Difficulté 4/5 3-5 jours Accessibilité débutants 55/100
callstack/react-native-brownfield#468 ·
Les mainteneurs répondent en général sous 4 jours
-
Difficulté 4/5 3-5 jours Accessibilité débutants 48/100
callstack/react-native-brownfield#420 ·
Les mainteneurs répondent en général sous 4 jours
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 38/100
callstack/react-native-brownfield#406 ·
Les mainteneurs répondent en général sous 4 jours
-
Common network layerPeut-être à nouveau libre @dratwas l’a pris il y a 2542 jours, et aucune pull request n’est ouverte. Ouverte
callstack/react-native-brownfield#23 · 1 personne assignée ·
Les mainteneurs répondent en général sous 4 jours
-
Add support for bottom tabsPeut-être à nouveau libre @krizzu l’a pris il y a 2542 jours, et aucune pull request n’est ouverte. Ouverte
callstack/react-native-brownfield#22 · 1 personne assignée ·
Les mainteneurs répondent en général sous 4 jours
Toutes les issues de callstack/react-native-brownfield
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
stellar/stellar-dev-skill#151 ·
Les mainteneurs répondent en général sous 1 jour
-
Trial & Error: guided Blind offer squeezes on phones and sits under the touch toolbar on iPadOuvertearea:arcade game ready-for-agent
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
fderuiter/deruiter.dev#2281 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
scope: data grid type: bug
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 2 jours
-
fix(frontend): correct VITE_IS_DEVELPOMENT typo in shared/app.ts and align dev environment flagsOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
vicharanashala/ajrasakha#1439 ·
Les mainteneurs répondent en général sous 1 jour
-
Add: TV5Monde AsieOuverteapproved check:passed streams:add
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
Les mainteneurs répondent en général sous 1 jour