I decided to create an application where users need to register and then log in. I implemented this functionality using Firebase Auth, and it works. However, a problem arose when I needed to assign each user a status (user, vip, premium) and record this in the database. According to my logic, after registration, the application receives the assigned UID of the user and then writes information about this user (username, status, expiration date of the status) into the Realtime Database using this UID.
However, the issue occurred when I tried to add the Firebase Database component to my project. With this component included, the compiled application closes immediately without any errors. I tried setting different values in the properties and even leaving them empty, as well as initializing the values directly in the initialization blocks, but nothing changed, and the application still closes immediately. I created a new empty project and added only two components: Firebase Core and Firebase Database, and the result was the same; the application closed again.
I took a different approach and used Firestore Database instead. In the project, I added the Firestore component, initialized it with the correct data in the initialization blocks, compiled the application, and upon launch, it now throws an error: “Runtime Error FirebaseApp with name second app doesn’t exist. Available app names: [DEFAULT]”. I don’t understand what this error means.
Please forgive me for the long message. I tried to explain the situation in detail.
I tried to copy the log of exactly what happens during the application startup into a text file.
The first log is from a plain text application with added Firebase Core and Firebase Database components, which closes immediately after launching without any errors. logFirebase Database.txt (196.1 KB)
The second log is from my application with Firestore, where the error I mentioned above occurs. logFirestore.txt (278.0 KB)
I continue to search for the causes of the errors and crashes. Here is what I managed to discover: If I add the google-services.json file downloaded from Firebase to the Assets folder and set UseJsonFile = true in the Firebase Core component, the error “FirebaseApp with name second app doesn’t exist. Available app names: [DEFAULT]” does not occur at startup. However, when using Firestore, specifically the GetAllDocs block, the application crashes again, i.e., it closes without any errors. I studied how to use the ADB utility a bit more and recorded new logs.
New log of the application using Firestore and crashing when the GetAllDocs block is executed: firestore_app_logs.txt (324.2 KB)
New log of the application using Firebase Database and crashing at startup: firebasdb_app_logs.txt (76.8 KB)