java.lang.IllegalStateException: FirebaseApp with name [DEFAULT]

前端 未结 3 1615
抹茶落季
抹茶落季 2020-12-10 11:24

I have been getting this issue.. followed the upgrade guide for new firebase sdk...saved the google services json file in app directory.. still the same error as you but for

3条回答
  •  无人及你
    2020-12-10 11:58

    Extending @Ian Barber's solution, you can try this generic check to skip processing your custom Application.onCreate for all non-main processes. If the additional processes don't belong to you, then you don't want any of your custom to run.

    @Override
    public void onCreate() {
        super.onCreate();
        if (FirebaseApp.getApps(this).isEmpty()) {
            // No firebase apps; we are in a non-main process
            // skip custom Application.onCreate
            return;
        }
        // Firebase init only in the main process
        FirebaseDatabase.getInstance().setPersistenceEnabled(true);
        // other code
    }
    

提交回复
热议问题