Skip to content

[Question] Unity desktop with Crashlytics + Analytics #1219

Open
@mmiro1

Description

@mmiro1

[REQUIRED] Please fill in the following fields:

  • Unity editor version: 2020.3.24f1
  • Firebase Unity SDK version: 8.7.0
  • Source you installed the SDK: .unitypackage
  • Problematic Firebase Component: Crashlytics
  • Other Firebase Components in use: Analytics
  • Additional SDKs you are using: non
  • Platform you are using the Unity editor on: Windows
  • Platform you are targeting: desktop
  • Scripting Runtime: Mono and IL2CPP

[REQUIRED] Please describe the question here:

Hi, I am trying to use Analytics and Crashlytics in my projects and I am having some problems with it. I just created a new project to make some testing and I get the same results, I don't see anything from the Firebase console. All the code I am using is the following one:

using Firebase;
using Firebase.Analytics;
using Firebase.Crashlytics;
using Firebase.Extensions;
using UnityEngine;
using UnityEngine.UI;

public class FirebaseManager : MonoBehaviour
{
    GameObject nullGameObject;
    FirebaseApp app;
    public Text text;

    void Start()
    {
        FirebaseApp.LogLevel = LogLevel.Debug;

        FirebaseApp.CheckAndFixDependenciesAsync().ContinueWithOnMainThread(task =>
        {
            var dependencyStatus = task.Result;
            if (dependencyStatus == DependencyStatus.Available)
            {
                // Create and hold a reference to your FirebaseApp,
                // where app is a Firebase.FirebaseApp property of your application class.
                // Crashlytics will use the DefaultInstance, as well;
                // this ensures that Crashlytics is initialized.
                app = FirebaseApp.DefaultInstance;

                // Set a flag here for indicating that your project is ready to use Firebase.
                //x = true;

                FirebaseAnalytics.SetAnalyticsCollectionEnabled(true);
                FirebaseAnalytics.LogEvent(FirebaseAnalytics.EventAppOpen);

                Debug.Log("Ready!");
                text.text = "Ready!";
            }
            else
            {
                Debug.LogError($"Could not resolve all Firebase dependencies: {dependencyStatus}");
                // Firebase Unity SDK is not safe to use here.
            }
        });
    }

    // Methods called by UI buttons

    public void Crash()
    {
        Debug.Log("Crash!");
        text.text = "Crash!";

        Crashlytics.LogException(new System.Exception("test"));
        throw new System.Exception("test exception please ignore");
    }

    public void NullCrash()
    {
        Debug.Log("Crash null!");
        text.text = "Crash null!";

        nullGameObject.transform.position = Vector3.zero;
    }

    public void Log()
    {
        Debug.Log("Log!");
        text.text = "Log!";

        FirebaseAnalytics.LogEvent(FirebaseAnalytics.EventLogin);

        FirebaseAnalytics.LogEvent(
            FirebaseAnalytics.EventLogin,
            new Parameter[] {
                new Parameter(FirebaseAnalytics.ParameterMethod, "hello"),
            }
        );
    }

}

As I undestand, with this code and enabling the Analytics and Crashlytics in the firebase project is enough to have it working. After that you only need to add the unity project to firebase as an android app and download the "google-services.json" + install the unity packages of Analytics and Crashlytics.

But in the console I get this output:

image

I supouse that the problem reside in that the app initializer crashlytics is not found, but i don't undestand why.

Am I missing any step or making something wrong? Do I have to make any extra step to have it working in desktop?
Also, can I test while running from the Unity editor without makeing a build?

Thank you in advance.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions