Skip to content

iOS support is required on Windows for a Firebase project, causing Unity to not respond when I build for Android #1003

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
pardo162 opened this issue Mar 24, 2021 · 7 comments

Comments

@pardo162
Copy link

pardo162 commented Mar 24, 2021

[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();
            }
        }
    }
}
@paulinon paulinon removed the new New issue. label Mar 24, 2021
@paulinon
Copy link
Contributor

Hi @pardo162,

I have followed the steps you've listed, but the behavior in my Android build is the same as the editor's. To be specific, the text changed to "done1" then "1". With that, could you confirm if this issue persists with just that code and the Database SDK in your project?

If so, please provide the logs from the Android Logcat when running your app so that I can identify what's causing your issue.

Additionally, I noticed that you're using an LTS version of Unity. A new version was released recently (2020.3.1f1), so it's possible that updating your Unity editor may resolve your issue.

Let me know how it goes.

Thanks!

@paulinon paulinon added the needs-info Need information for the developer label Mar 24, 2021
@pardo162
Copy link
Author

pardo162 commented Mar 25, 2021

LogCast.txt
Hi
Here is the log I have not managed to fix anything.
It does not give any error, it just does not respond.
sometimes responds by taking several minutes.
I also tried the latest version of Unity 2019 but nothing.

@google-oss-bot google-oss-bot added needs-attention Need Googler's attention and removed needs-info Need information for the developer labels Mar 25, 2021
@paulinon
Copy link
Contributor

Hi @pardo162,

The latest version of the Unity editor is version 2021.1.0. Could you try using this version and see if the issue is fixed? If not, please provide a minimal, reproducible example of your project. The cause of this behavior may come from within your project.

@paulinon paulinon added needs-info Need information for the developer and removed needs-attention Need Googler's attention labels Mar 25, 2021
@pardo162
Copy link
Author

Hi
ok I'm going to download that version

I have some questions:
I installed IOS support because I had these errors
is there any other way to solve these errors?
could that be causing problems? I don't need IOS support
Crash

another question
in project settings > player > other settings > Api compatibility level
for default it is Net.2 Standard
should I change to .Net4?

the google-services shold be inside Assts folder or Assts / StreamingAssets?

@google-oss-bot google-oss-bot added needs-attention Need Googler's attention and removed needs-info Need information for the developer labels Mar 25, 2021
@patm1987
Copy link

Hi @pardo162 ,

It looks like it will be necessary to add iOS support to your Unity installation to use Firebase. It looks like this issue is related to googlesamples/unity-jar-resolver#412 (the error you're seeing in Google.IOSResolver_v1.2.164.dll) and appears to also effect Firebase dll's Firebase.Editor.dll and Firebase.Crashlytics.Editor.dll. A workaround mentioned in the linked bug suggests disabling some dlls to get it to work, but I would recommend against this in this case as you'd probably silently disable some of Crashlytics' core functionality.

Adding iOS support is the best workaround for now. I know that this isn't ideal and I will leave this open as a bug though since this shouldn't be required (in our testing, because of the dependency on CocoaPods, Windows versions of Unity cannot export a buildable XCode project with Firebase or other EDM4U libraries). Image included for others who stumble across this:
image

The issue is that some of our libraries that edit XCode projects included using UnityEditor.iOS.Xcode; -- which can't be #ifdef'ed out since this ships as a compiled dll. The code is skipped if your target isn't, but because of the using statement, Unity tries to pull it in regardless. I'm told that this behaviour is different since earlier versions of Unity, but I can confirm that I see it on Windows with Unity 2020.3.1f1.

For your other questions:

  • API compatibility level can be .NET 2 Standard. It's a quirk of .NET versioning (see this chart, which shows that .NET Standard 2.0 is actually .NET 5.0 and .NET Framework 4.6.1), and a moderate annoyance since Firebase still supports versions of Unity that only supports .NET 3.0.
  • google-services should be in Assets. It's converted at build time to the file Assets/Plugins/Android/Firebase.androidlib/res/values/google-services.xml, which is included directly by the built Android project. More information on this process here.

@patm1987 patm1987 changed the title Firebase is not responding when I build for Android iOS support is required on Windows for a Firebase project, causing Unity to not respond when I build for Android Mar 25, 2021
@patm1987 patm1987 added type: bug and removed needs-attention Need Googler's attention labels Mar 25, 2021
@pardo162
Copy link
Author

pardo162 commented Mar 25, 2021

I manage to solve the problem of IOS build support, now I only have Android build support, but my APK still does not respond.
Unity 2021.1.0. is only giving me more problems.
that version is new and unstable.
I already have a minimal, reproducible example prepared.
I created the APK (with the problem), an Export for Android Studio and The Unity project.
if you give me an email I can share the folder.

@pardo162
Copy link
Author

What do i do now? I'm done with my game and the only thing I need to launch it is the connection to firebase
have you already managed to replicate the bug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants