I cannot access my firebase/firecloud data from my flutter project. I get: Could not reach Cloud Firestore backend. Connection failed 1 times
- First include firebase_core in your dependencies
firebase_core: ^1.3.0
. - The screenshot you sent is firebase Realtime database (rtdb). But what you are trying to reach is cloud firestore. Did you setup cloud firestore? Confirm by going to firebase console and clicking cloud firestore by the left. Check if it is setup and if you have any data in the 'controls' collection.
- Go to the link given in 'errors screenshot' that you posted and enable cloud firestore api.
NB: Cloud firestore and Realtime database are 2 different firebase databases. You can visit this link to learn about their differences and decide which one to use.
kojo justine
Updated on December 31, 2022Comments
-
kojo justine over 1 year
I have been stuck with this for days now, I have difficulty accessing my firebase database from my flutter project. I have followed all the instructions to adding firebase to an android app on flutter and tried many suggested solutions on the web but I'm still stuck. I hope someone will be patient or kind enough to help me out. I have put all the necessary snippets below.
My dependencies
dependencies: flutter: sdk: flutter google_maps_flutter: ^2.0.6 proj4dart: ^2.0.0 location: ^4.2.0 cloud_firestore: ^2.5.1 firebase_core: ^1.6.0
my imports
import 'dart:async'; import 'package:flutter/material.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:cloud_firestore/cloud_firestore.dart';
my function to retrieve the data from firestore
Future getControls() async{ await Firebase.initializeApp(); FirebaseFirestore firestoreInstance = FirebaseFirestore.instance; QuerySnapshot data = await firestoreInstance.collection('Controls').get(); }
My google service JSON file
**
I may not be doing it right, or there is something I'm missing. Can someone please help me out .... mmmhh. Thanks in Advance
**
-
kojo justine over 2 yearsO, thanks for the corrections. I have added the firebase_core dependency to my project. I have now setup a cloud firetore database and also, I have enabled the API. however, I am still receiving similar errors: Listen for Query(target=Query(controls order by name);limitType=LIMIT_TO_FIRST) failed: Status{code=PERMISSION_DENIED, description=Missing or insufficient permissions., cause=null} Any ideas where to go next?
-
kojo justine over 2 yearsok. I changed the rules at the firestore into: allow read, write;
-
Peter Obiechina over 2 yearsAwesome. Glad I could help.