为什么未初始化Fabric? java.lang.IllegalStateException:必须在使用singleton()之前初始化Fabric [英] Why is Fabric not initialized? java.lang.IllegalStateException: Must Initialize Fabric before using singleton()

查看:163
本文介绍了为什么未初始化Fabric? java.lang.IllegalStateException:必须在使用singleton()之前初始化Fabric的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我根据开始使用Firebase Crashlytics 来设置Firebase Crashlytics Android应用(使用Android Studio 3.1.3)。在我自己的设备以及仿真器上,一切正常,并且我的崩溃在Firebase控制台中正确显示。到目前为止,一切都很好。

I set up Firebase Crashlytics according to Get started with Firebase Crashlytics for my Android app (using Android studio 3.1.3). On my own device as well as on the Emulator, everything works fine and my crashes appear correctly within the Firebase Console. So far so good.

但是,我的一个应用程序用户发生了意外崩溃:

However, there was a crash for one of my app users that was unexpected:


java.lang.IllegalStateException:必须在使用singleton()之前初始化Fabric

java.lang.IllegalStateException: Must Initialize Fabric before using singleton()

除了MainActivity之外,还有另一个Activity。

The exception was thrown in another Activity than the MainActivity.

我知道您可以按照通过调用 Fabric.with(this,new Crashlytics()); 来在此处初始化上面提到的入门指南文章中没有提到必须手动初始化Crashlytics。我期望这是自动完成的,因为我自己的所有测试都运行良好。那么,为什么对于某些用户而言Crashlytics设置正确而对于某些用户而言却没有正确设置?

I am aware that you could manually execute the initialization as described here by calling Fabric.with(this, new Crashlytics()); However, there is nothing said about one has to manually initialize the Crashlytics in the Getting Started article mentioned above. I was expecting this is done automatically since all my own tests run fine. So why is it that for some users Crashlytics is set up correctly and for some not?

推荐答案

您需要在自己的系统中初始化Crashlytics应用程序的onCreate

You need to initialize Crashlytics in your application's onCreate

import android.app.Application;

import com.crashlytics.android.Crashlytics;

import io.fabric.sdk.android.Fabric;

public class TestApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        Fabric.with(this, new Crashlytics());
    }
}

这篇关于为什么未初始化Fabric? java.lang.IllegalStateException:必须在使用singleton()之前初始化Fabric的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆