title: Unity Firebase C# - How to post to database from android apk instead of editor?
body: <p>I have firebase in my unity project. I have a function that posts a json to the database: </p>
  
  <pre><code>public void PostToDatabase(){
          //Convert both objects to json files [string]
          Player1Json = ConvertToJson(Player1Data);
          Player2Json = ConvertToJson(Player2Data);
  
          if (Data.HostPlayer)  {
              FBDatabase.GetReference("GameID:" + Data.gameID.ToString()).Child("WinVal").SetValueAsync(win);
              FBDatabase.GetReference("GameID:" + Data.gameID.ToString()).Child("PlayersConnected").SetValueAsync(playersConnected);
              FBDatabase.GetReference("GameID:" + Data.gameID.ToString()).Child("Player1").SetRawJsonValueAsync(Player1Json);
  
          }
          else if(Data.ClientPlayer) {
              FBDatabase.GetReference("GameID:" + Data.gameID.ToString()).Child("WinVal").SetValueAsync(win);
              FBDatabase.GetReference("GameID:" + Data.gameID.ToString()).Child("PlayersConnected").SetValueAsync(playersConnected);
              FBDatabase.GetReference("GameID:" + Data.gameID.ToString()).Child("Player2").SetRawJsonValueAsync(Player2Json);
          }
          UpdateFromDatabase();
      }
  </code></pre>
  
  <p>This works fine in the editor. However, when I build the project to windows, android, etc. the data never posts because database is never ready to use(or something). How do I make it so I can post and update data from the database on an android apk or a unity build on windows the same way it works in the editor??</p>
  
  <p>I've been struggling for weeks with this and can't find a solution anywhere. Here is the start function:</p>
  
  <pre><code>void Start(){
          // Set this before calling into the realtime database.
          FirebaseApp.DefaultInstance.SetEditorDatabaseUrl("https://MY-PROJECT.firebaseio.com/");
          FBDatabase = FirebaseDatabase.DefaultInstance;
  
  
          //Initialize both players' data [Data]
          Player1Data = new Data();
          Player2Data = new Data();
  
          //Increment how many players are connected [int]
          playersConnected++;
      }
  </code></pre>
  
  <p><strong>UPDATE</strong>
  Here is what log cat is saying:
  <a href="https://i.stack.imgur.com/wh1X6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wh1X6.png" alt="LogCatErrors"></a></p>
  
  <p><strong>UPDATE 2</strong>
  I downloaded Android Studio and tried to run the gradle project and received these errors:</p>
  
  <p>05/15 13:10:03: Launching 'launcher' on motorola moto g(6) play.
  $ adb shell am start -n "com.DefaultCompany.RtsDefense/com.unity3d.player.UnityPlayerActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
  Error while executing: am start -n "com.DefaultCompany.RtsDefense/com.unity3d.player.UnityPlayerActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
  Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.DefaultCompany.RtsDefense/com.unity3d.player.UnityPlayerActivity }
  Error type 3
  Error: Activity class {com.DefaultCompany.RtsDefense/com.unity3d.player.UnityPlayerActivity} does not exist.</p>
  
  <p>Error while Launching activity</p>