In my project am using React native firebase to get Analytics and my project is expo bare flow, I just followed this https://rnfirebase.io/ Document but while running the app am getting error like
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.
My Android MainApplication.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;
}
package.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",
I tried with config-plugin https://docs.expo.dev/guides/config-plugins/ also but no use, the error is not solved.
I have an expo app and used this link...
May be different if you ejected expo or started with bareworkflow
https://docs.expo.dev/guides/using-firebase/#using-expo-with-firestore
have a firebase.js file and import the different modules you will need
showing ours as an example
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]
be sure you have the @firebase/module-name added per FB package install guide