My app is connected to firebase and auth is working fine. However, when trying to use firestore I can't figure out this problem.
Possible Unhandled Promise Rejection (id: 0): Error: No Firebase App '[DEFAULT]' has been created - call firebase.initializeApp()
I am getting the above error however, I am already calling initializeApp and not sure what else to try. I am trying to get access to a collection on firestore and print it out but it gives me the error when I try to access firestore.
I have tried doing console.log(firebase.app().name) which gives the name of the app, so not sure how it is not initialised.
var firebaseConfig = {
apiKey: "***",
authDomain: "***",
databaseURL: "***",
projectId: "***",
storageBucket: "***",
messagingSenderId: "***",
appId: "***",
measurementId: "****",
}
firebase.initializeApp(firebaseConfig)
const db = firebase.firestore()
My imports are
import "firebase/firestore"
import firebase from "firebase"
import firestore from "@react-native-firebase/firestore"
I have tried so many different questions on here and forums but nothing has helped
My app is connected to firebase and auth is working fine. However, when trying to use firestore I can't figure out this problem.
Possible Unhandled Promise Rejection (id: 0): Error: No Firebase App '[DEFAULT]' has been created - call firebase.initializeApp()
I am getting the above error however, I am already calling initializeApp and not sure what else to try. I am trying to get access to a collection on firestore and print it out but it gives me the error when I try to access firestore.
I have tried doing console.log(firebase.app().name) which gives the name of the app, so not sure how it is not initialised.
var firebaseConfig = {
apiKey: "***",
authDomain: "***",
databaseURL: "***",
projectId: "***",
storageBucket: "***",
messagingSenderId: "***",
appId: "***",
measurementId: "****",
}
firebase.initializeApp(firebaseConfig)
const db = firebase.firestore()
My imports are
import "firebase/firestore"
import firebase from "firebase"
import firestore from "@react-native-firebase/firestore"
I have tried so many different questions on here and forums but nothing has helped
Share Improve this question edited Feb 5, 2020 at 15:02 Frank van Puffelen 600k85 gold badges889 silver badges859 bronze badges asked Feb 5, 2020 at 11:42 duronicduronic 1671 gold badge3 silver badges11 bronze badges 7- 1 Have you added 'GoogleServiceInfo.plist' in your project ? – Kishan Bharda Commented Feb 5, 2020 at 12:25
- @KishanBharda i'm only developing for Android so I don't think I need it right? – duronic Commented Feb 5, 2020 at 12:52
- 2 Ok, so you have to add 'GoogleService.json' in your project at yourProject/android/app. – Kishan Bharda Commented Feb 5, 2020 at 12:53
- @KishanBharda followed the docs and added that in, i'm now getting an error saying caller does not have permission to execute the specified operation. Which is a step forward I think. Thank you – duronic Commented Feb 5, 2020 at 13:17
- 1 Can you post your solution as answer ? So It helps to others. – Kishan Bharda Commented Feb 5, 2020 at 13:31
2 Answers
Reset to default 4Make sure that you made all the configuration correctly by following this video
And just make sure that the first 2 lines at main function are (follow the same order):
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
//rest of the code
runApp(MyApp());
}
As per Kishan above. I added the google-services.json file into the android level folder and modified both build.gradle files.
https://firebase.google./docs/android/setup followed step 3 here to update the build.gradle files to use google-services.