En mi proyecto, estoy usando React native firebase para obtener Analytics y mi proyecto es expo bare flow, solo seguí este documento https://rnfirebase.io/ pero mientras ejecuto la aplicación recibo un error como
backend.js:2173 Possible Unhandled Promise Rejection (id: 3): Error: You attempted to use a firebase module that's not installed on your Android project by calling firebase.app(). Ensure you have: 1) imported the 'io.invertase.firebase.app.ReactNativeFirebaseAppPackage' module in your 'MainApplication.java' file. 2) Added the 'new ReactNativeFirebaseAppPackage()' line inside of the RN 'getPackages()' method list. See http://invertase.link/android for full setup instructions. Error: You attempted to use a firebase module that's not installed on your Android project by calling firebase.app(). Ensure you have: 1) imported the 'io.invertase.firebase.app.ReactNativeFirebaseAppPackage' module in your 'MainApplication.java' file. 2) Added the 'new ReactNativeFirebaseAppPackage()' line inside of the RN 'getPackages()' method list.Mi aplicación principal de Android.java
import io.invertase.firebase.app.ReactNativeFirebaseAppPackage; <---added for firebase private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { @Override public boolean getUseDeveloperSupport() { return BuildConfignfig.DEBUG; } @Override protected List<ReactPackage> getPackages() { List<ReactPackage> packages = new PackageList(this).getPackages(); packages.add(new ModuleRegistryAdapter(mModuleRegistryProvider)); packages.add(new ReactNativeFirebaseAppPackage());<---- added for firebase return packages; }paquete.json
"@react-native-firebase/analytics": "^13.0.1", "@react-native-firebase/app": "^13.0.1", "@types/npm": "^7.19.0", "apisauce": "^0.15.1", "base-64": "^0.1.0", "expo": "~42.0.1", "expo-blur": "~9.0.3", "expo-camera": "^11.2.2", "expo-linear-gradient": "~9.2.0", "expo-secure-store": "~10.2.0", "expo-splash-screen": "~0.11.2", "expo-status-bar": "~1.0.4", "expo-updates": "~0.8.1", "native-base": "^2.15.2", "react": "16.13.1", "react-dom": "16.13.1", "react-native": "~0.63.4",Intenté con el complemento de configuración https://docs.expo.dev/guides/config-plugins/ también pero no funcionó, el error no se resuelve.
Tengo una aplicación de exposición y usé este enlace...
Puede ser diferente si expulsó la exposición o comenzó con bareworkflow
https://docs.expo.dev/guides/using-firebase/#using-expo-with-firestore
tenga un archivo firebase.js e importe los diferentes módulos que necesitará
mostrando el nuestro como ejemplo
import { initializeApp } from "firebase/app" import { getFirestore } from 'firebase/firestore'; import Constants from "expo-constants" import "firebase/auth" // TODO: Add SDKs for Firebase products that you want to use // https://firebase.google.com/docs/web/setup#available-libraries // Your web app's Firebase configuration -- from firebase console // For Firebase JS SDK v7.20.0 and later, measurementId is optional const firebaseConfig = { apiKey: xxxxxxx, authDomain: xxxxxxx, databaseURL: xxxxxxxxx, projectId: xxxxxxxxx, storageBucket: xxxxxxxxx, messagingSenderId: xxxxxxxxx, appId: xxxxxxxxx, measurementId: xxxxxxxxx, } // Initialize Firebase const Firebase = initializeApp(firebaseConfig) const firestore = getFirestore(); <--- our added firestore module export default [Firebase, firestore]asegúrese de tener @firebase/module-name agregado según la guía de instalación del paquete FB