I am trying to build a simple login user authentication Android application that uses Firebases Realtime Database but I am getting the error:
[Firebase Database connection was forcefully killed by the server. Will not attempt to reconnect. Reason: The database lives in a different region. Please change your database URL to https://vax-in-60807-default-rtdb.asia-southeast1.firebasedatabase.app]
I am currently using the Singapore(asia-southeast1) server since I live in the Philippines. Is this wrong? or Should I be using the US one? How do I change my Database URL?
It looks like the google-services.json file that you use doesn't contain the Realtime Database URL, probably because you downloaded it before the database was created. In such cases the SDK assumes that the database is in the US (the original region), and you get an error that there's a mismatch.
There are two possible solutions:
Download an updated google-services.json from the Firebase console, and add that to your Android app.
Specify the database URL in your code instead, like this: FirebaseDatabase.getInstance("https://vax-in-60807-default-rtdb.asia-southeast1.firebasedatabase.app")...
Both have the same result, so pick whichever one seems easiest to you.
It cat still not work after the accepted answer (as in my case). If so, try:
Clean Project
Rebuild Project
Invalidate Caches & Restarte
and run it again.
If you are a New Flutter User who followed the new firebase doc, run this command in the terminal. It will automatically update the firebase_options.dart file.
flutterfire configure
I faced the same problem and that's because when you set up the app, the google-service.json doesn't contain the firebase_url.
These problems faced you when configuring your set up manually, You can fix all that problems by using flutterfire, it will help you a lot and set up your app in a few steps.
see docs firebase
It looks like the google-services.json file that you use doesn't contain the Realtime Database URL, probably because you downloaded it before the database was created. In such cases, the SDK assumes that the database is in the US (the original region), and you get an error that there's a mismatch.
You can fix it either way.
After configuring the database service setup you have to download the new "GoogleService-Info.plist" file and replace the previous one.
or
You can manually set the key in your "GoogleService-Info.plist" file
<key>DATABASE_URL</key>
<string>https://<app-instance-default-rtdb>.asia-southeast1.firebasedatabase.app</string> '
Related
I am trying to build a simple login user authentication Android application that uses Firebases Realtime Database but I am getting the error:
[Firebase Database connection was forcefully killed by the server. Will not attempt to reconnect. Reason: The database lives in a different region. Please change your database URL to https://vax-in-60807-default-rtdb.asia-southeast1.firebasedatabase.app]
I am currently using the Singapore(asia-southeast1) server since I live in the Philippines. Is this wrong? or Should I be using the US one? How do I change my Database URL?
It looks like the google-services.json file that you use doesn't contain the Realtime Database URL, probably because you downloaded it before the database was created. In such cases the SDK assumes that the database is in the US (the original region), and you get an error that there's a mismatch.
There are two possible solutions:
Download an updated google-services.json from the Firebase console, and add that to your Android app.
Specify the database URL in your code instead, like this: FirebaseDatabase.getInstance("https://vax-in-60807-default-rtdb.asia-southeast1.firebasedatabase.app")...
Both have the same result, so pick whichever one seems easiest to you.
It cat still not work after the accepted answer (as in my case). If so, try:
Clean Project
Rebuild Project
Invalidate Caches & Restarte
and run it again.
If you are a New Flutter User who followed the new firebase doc, run this command in the terminal. It will automatically update the firebase_options.dart file.
flutterfire configure
I faced the same problem and that's because when you set up the app, the google-service.json doesn't contain the firebase_url.
These problems faced you when configuring your set up manually, You can fix all that problems by using flutterfire, it will help you a lot and set up your app in a few steps.
see docs firebase
It looks like the google-services.json file that you use doesn't contain the Realtime Database URL, probably because you downloaded it before the database was created. In such cases, the SDK assumes that the database is in the US (the original region), and you get an error that there's a mismatch.
You can fix it either way.
After configuring the database service setup you have to download the new "GoogleService-Info.plist" file and replace the previous one.
or
You can manually set the key in your "GoogleService-Info.plist" file
<key>DATABASE_URL</key>
<string>https://<app-instance-default-rtdb>.asia-southeast1.firebasedatabase.app</string> '
I'm going to use cloud functions for firebase to recursively delete documents and collections in Firestore that is triggered by HTTP request (I'm using HTTP Callable function specifically). I have found some useful information from the following links:
https://firebase.google.com/docs/functions/callable
https://firebase.google.com/docs/firestore/solutions/delete-collections
But I'm not sure about one thing: It looks like from the tutorial, the functions are written locally and then deployed to cloud server. So where do I keep all the functions and their dependencies? If I keep the local written function within my android project, then each time when I update the function locally I will have to publish a new version of the app, which is too much work. Is it ok to start the local written function in another folder other than the android project? Also, if I want to start writing the function directly at cloud functions at GCP (so that I can update the function in cloud server), where can I get the dependencies files such as package.json, package-lock.json and .eslintrc.json etc.? I didn't find useful tutorial to that. Can someone help me? Thanks!
To answer your questions, first you can keep your functions and dependencies anywhere as long as you have access and logged your account to the CLI with the right project configured in it. Each time you update your function locally then yes, you have to redeploy it.
If you want, you can consider setting up CI/CD with your Firebase Functions so you can automate deployments whenever you hit commit on master and staging branch of your repo.
Second, you can start the local written function anywhere, as long as it contains the right dependencies for your app. As Doug mentioned, it doesn't matter how your files are organized.
And third, the dependencies files such as package.json, package-lock.json, and .eslintrc.json is something that you need to provide on your own. I suggest that you read through their docs and see what works best for you.
If I keep the local written function within my android project, then each time when I update the function locally I will have to publish a new version of the app, which is too much work.
That's not true. It doesn't really matter where you project files are organized. You can still deploy the function whenever you want. It's completely separate from your app code.
Is it ok to start the local written function in another folder other than the android project?
If that's your preference, then do it. As I mentioned, it doesn't matter how your files are organized.
Also, if I want to start writing the function directly at cloud functions at GCP (so that I can update the function in cloud server), where can I get the dependencies files such as package.json, package-lock.json and .eslintrc.json etc.?
If you're having problems working with functions in the console, you should ask a separate question about that and indicate where you are stuck in that process.
I am building an android application and I am facing some weird issues related to FIREBASE DATABASE.
I have created a firebase database and added some tables, fields and added some data, like;
Log in with phone authentications etc.
I can use this database with my android app, but I can't be able to see the database.
I have tried a lot to refresh again and again, but not working.
If someone is using firebase, then please login to the console. firebase and check if you can see it, might be, GOOGLE changes its UI (User Interface).
Help me, please!
It will be a great favor.
I think you are not selecting your project:
Check if that is your project, or change it.
If it's prompting you to create a database for that project, it is because that is not the project you are working on. You need to select the current project you are working on in order to see your database.
There are two options - 1. Realtime Database i.e. Firebase. 2. Cloud FireStore. You have to select 1 instaed of 2. See the image below
I was experiencing the same problem. I was worried that all the data might have been deleted. I just left the tab open and after few minutes the database and its children started showing. I think if your database contains a lot of data, it takes time to load the data.
You have to click on Create Database button and setup rules before you try to save data on database. Remember Your are only setting up rules here not giving any database name.
I'm building a library that is using Firebase database.
when i'm taking the exported .aar and importing it via another app - i get the following error:
FirebaseAuthException: This operation is not allowed
the original app didnt allow the firebase database option - so we get this message. problem is I don't need to use the app's Firebase database within the sdk - what I want is the lib's (aar) firebase database to modify.
maybe if there was a way to define two google-services.json files, one for the aar and one for the app - without them overriding themselves?
how can an autonomous firebase database within a library?
You basically need to have an instance of FirebaseApp created from your library credentials. See this blog, it might help.
Instead of creating and managing 2 different google.json files (I'm not sure whether it's possible or not but even if it is..), i think it's better to wrap your library's firebase database instance and expose a neat api for the consumer apps to interact with your library's database.
I've set-up up my AS to use Firebase. How to know/change the Firebase app/Database I'm using in my app from Android Studio?
If you have already setted your project, you must have downloaded a google-services.json and put it in the app folder. So, in that json, you can find your database url.