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.
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 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 am developing an Android app to share doc(generally pdf) between student and teachers(two different app one as a server and another as a client).Uploading a file to the firebase storage is done. The problem is that I want a list of uploaded file with download thumbnail/button in the student app. How to do it?
Please help me out.
I don't think you can do it as there is no API till now. All you can do is Store the link generated for each file in the Realtime database and then use this list of URL.
Or use cloud functions to manipulate your uploads and then store generated URL in some file and retrieve this file for list of files.
For more please refer this post.
https://stackoverflow.com/a/37337436/4517450
https://firebase.google.com/docs/database/
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 created an Android app with package name 'com.theapp.app1' initially when setting up my Firebase for the first time. But later I decided to change my app name from 'com.theapp.app1 to 'com.theapp.app2'. I refactored my package name in Android Studio but got an error 'Gradle does not recognize 'com.theapp.app2' in google-services.json file.
In app1 I have created a json database which I want to copy to app2 in firebase without re-creating a new database in app2. Plus, I want to delete app1 after copying its db content.
I tried renaming the app1 name to app2 in firebase but I figured out that it is impossible.
Is there a way to achieve this without the need to create a new json database in Firebase?
I think i can answer my question. #has9 suggestions helped me figure out that the Json database is not directly tied to an app on firebase. that is, when you create another app (app2) and delete app1, your database will not be deleted with app1. i hope i explained my answer clearly. anyways this solved my problem.