Open
Description
[REQUIRED] Please fill in the following fields:
- Unity editor version: 2020.3.0.f1
- Firebase Unity SDK version: 7.1.0
- Source you installed the SDK: Unity Package Manager
- Problematic Firebase Component: App, RealtimeDatabase
- Other Firebase Components in use: Auth.
- Additional SDKs you are using: AdMob.
- Platform you are using the Unity editor on: Windows.
- Platform you are targeting: Android.
- Scripting Runtime: IL2CPP
[REQUIRED] Please describe the issue here:
From what I have been able to observe the database does not give an answer, it does not give the data or an error.
The problem appears in the APK not in the Editor. In the Editor it works.
Steps to reproduce:
do you need my Unity package name?
create a test database with:
season = 1
1 create a 3D project in Unity.
2 create the script "testFB".
3 copy and paste the code (code at the end).
4 create any object in the scene "Create Empty".
5 add the script "testFB" to the new object.
6 create a Canvas then panel and inside a Text.
7 adjust the sizes of the GUI.
8 add the created Text to the script in Result.
9 the project must run in the editor. Should read "1" from the database.
10 build the project for Android and it will stop working
Relevant Code:
// TODO(you): code here to reproduce the problem
using System.Collections;
using UnityEngine;
using UnityEngine.UI;
using Firebase;
using Firebase.Database;
using System.Text;
public class testFB : MonoBehaviour
{
private FirebaseApp app;
DependencyStatus dependencyStatus;
public Text result;
public int season;
bool ready;
void Start()
{
season = 10;
Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => {
dependencyStatus = task.Result;
if (dependencyStatus == DependencyStatus.Available)
{
app = Firebase.FirebaseApp.DefaultInstance;
ready = true;
}
else
{
Debug.LogError(System.String.Format(
"Could not resolve all Firebase dependencies: {0}", dependencyStatus));
}
});
StartCoroutine(ReadSeason());
}
private IEnumerator ReadSeason()
{
//Query season numbre should return: 1
yield return new WaitForSeconds(1f);
Debug.Log("done1");
result.text = "done1";
if (ready)
{
DataSnapshot snapshot;
DatabaseReference reference = FirebaseDatabase.DefaultInstance.GetReference("season");
var DBtask = reference.GetValueAsync();
yield return new WaitUntil(predicate: () => DBtask.IsCompleted);
//<-- Here it stops working, it just waits for an answer.
result.text = "done2";
Debug.Log("done2");
if (DBtask.Exception != null)
{
Debug.Log("no");
result.text = "no";
result.text = DBtask.Exception.ToString();
}
else
{
Debug.Log("yes");
result.text = "yes";
snapshot = DBtask.Result;
season = int.Parse(snapshot.Value.ToString());
Debug.Log(season.ToString());
result.text = season.ToString();
}
}
}
}