Search Unity

Question Unity Firebase SDK Problem

Discussion in 'Scripting' started by lakisha_, Feb 1, 2023.

  1. lakisha_

    lakisha_

    Joined:
    Dec 5, 2021
    Posts:
    2
    I've installed Unity Firebase SDK, firebase google-services and configured Player Settings with com project name. After that, I've written the following lines of code:

    Code (CSharp):
    1. private DatabaseReference _databaseReference;
    2.     private string _userID;
    3.  
    4.     private void Start()
    5.     {
    6.         _databaseReference = FirebaseDatabase.DefaultInstance.RootReference;
    7.         _userID = SystemInfo.deviceUniqueIdentifier;
    8.     }
    Even though I followed the steps from the official documentation, I got an error:
    DatabaseException: Failed to get FirebaseDatabase instance: Specify DatabaseURL within FirebaseApp or from your GetInstance() call.
    Firebase.Database.FirebaseDatabase.GetInstance (Firebase.FirebaseApp app, System.String url)


    Can someone help me please? :)
     
  2. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,187
    Looks like you don't have your Firebase json file dowloaded with your database info. If you created your database on Firebase, you also need to redownload the google file that will now contain the database info as well.
     
    yashubhati and AteranTeaOh like this.
  3. NEMZAKI

    NEMZAKI

    Joined:
    Apr 29, 2022
    Posts:
    6
    Am getting the same error even with the Firebase json file downloaded
     
  4. ebobo225

    ebobo225

    Joined:
    Apr 6, 2020
    Posts:
    2
    some one realeze this problem ?
     
  5. YousafGrewal

    YousafGrewal

    Joined:
    Jul 5, 2018
    Posts:
    29
    First i start encounter this problem but i solved using this code in start method


    AppOptions options = new AppOptions
    {
    DatabaseUrl = new System.Uri("https://imposter-killer-955fd-default-rtdb.firebaseio.com/")
    };
    // Create a new FirebaseApp instance with options
    app = FirebaseApp.Create(options);
    // Get the FirebaseDatabase instance using the FirebaseApp
    firebaseDatabase = FirebaseDatabase.GetInstance(app, "https://imposter-killer-955fd-default-rtdb.firebaseio.com/");


    But after working for a while, it encounters again and still i am facing this issue.