Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

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

Ouverte Adaptée aux débutants
#492 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub

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
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
android, kotlin, react-native
Domaine
mobile

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

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de callstack/react-native-brownfield

Toutes les issues de callstack/react-native-brownfield

Issues similaires

Plus d'issues TypeScript

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.