Ad

ExceptionInInitializerError With Firebase And Facebook

I recently upgraded firebase to the latest versions and am now using a custom token generated by our servers to authenticate. I am also doing a custom initialization of my firebase instance as explained here https://firebase.googleblog.com/2017/03/take-control-of-your-firebase-init-on.html . The initialization is done as the 3rd line of my application onCreate method (after calling super and setting a static instance variable) so it is as early as I can make it.

I get the following exception, but it's not consistently reproducible so it seems like some kind of race condition between firebase and facebook sdks.

E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
    java.lang.ExceptionInInitializerError
        at com.google.firebase.perf.internal.RemoteConfigManager.zzcb(Unknown Source)
        at com.google.firebase.perf.internal.FeatureControl.<init>(Unknown Source)
        at com.google.firebase.perf.internal.FeatureControl.zzar(Unknown Source)
        at com.google.firebase.perf.internal.GaugeManager.<init>(Unknown Source)
        at com.google.firebase.perf.internal.GaugeManager.zzbf(Unknown Source)
        at com.google.android.gms.internal.firebase-perf.zzat.<init>(Unknown Source)
        at com.google.android.gms.internal.firebase-perf.zzat.zza(Unknown Source)
        at com.google.firebase.perf.network.FirebasePerfUrlConnection.instrument(Unknown Source)
        at com.facebook.GraphRequest.createConnection(GraphRequest.java:1410)
        at com.facebook.GraphRequest.toHttpConnection(GraphRequest.java:1070)
        at com.facebook.GraphRequest.executeBatchAndWait(GraphRequest.java:1158)
        at com.facebook.GraphRequest.executeBatchAndWait(GraphRequest.java:1134)
        at com.facebook.GraphRequest.executeBatchAndWait(GraphRequest.java:1118)
        at com.facebook.GraphRequest.executeAndWait(GraphRequest.java:1093)
        at com.facebook.GraphRequest.executeAndWait(GraphRequest.java:987)
        at com.facebook.internal.FetchedAppSettingsManager.getAppSettingsQueryResponse(FetchedAppSettingsManager.java:207)
        at com.facebook.internal.FetchedAppSettingsManager.access$100(FetchedAppSettingsManager.java:47)
        at com.facebook.internal.FetchedAppSettingsManager$1.run(FetchedAppSettingsManager.java:122)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
        at java.lang.Thread.run(Thread.java:762)
     Caused by: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.coffeemeetsbagel. Make sure to call FirebaseApp.initializeApp(Context) first.
        at com.google.firebase.FirebaseApp.getInstance(com.google.firebase:[email protected]@16.0.4:240)
        at com.google.firebase.remoteconfig.FirebaseRemoteConfig.getInstance(Unknown Source)
        at com.google.firebase.perf.internal.RemoteConfigManager.<init>(Unknown Source)
        at com.google.firebase.perf.internal.RemoteConfigManager.<clinit>(Unknown Source)
        at com.google.firebase.perf.internal.RemoteConfigManager.zzcb(Unknown Source) 
        at com.google.firebase.perf.internal.FeatureControl.<init>(Unknown Source) 
        at com.google.firebase.perf.internal.FeatureControl.zzar(Unknown Source) 
        at com.google.firebase.perf.internal.GaugeManager.<init>(Unknown Source) 
        at com.google.firebase.perf.internal.GaugeManager.zzbf(Unknown Source) 
        at com.google.android.gms.internal.firebase-perf.zzat.<init>(Unknown Source) 
        at com.google.android.gms.internal.firebase-perf.zzat.zza(Unknown Source) 
        at com.google.firebase.perf.network.FirebasePerfUrlConnection.instrument(Unknown Source) 
        at com.facebook.GraphRequest.createConnection(GraphRequest.java:1410) 
        at com.facebook.GraphRequest.toHttpConnection(GraphRequest.java:1070) 
        at com.facebook.GraphRequest.executeBatchAndWait(GraphRequest.java:1158) 
        at com.facebook.GraphRequest.executeBatchAndWait(GraphRequest.java:1134) 
        at com.facebook.GraphRequest.executeBatchAndWait(GraphRequest.java:1118) 
        at com.facebook.GraphRequest.executeAndWait(GraphRequest.java:1093) 
        at com.facebook.GraphRequest.executeAndWait(GraphRequest.java:987) 
        at com.facebook.internal.FetchedAppSettingsManager.getAppSettingsQueryResponse(FetchedAppSettingsManager.java:207)  

Update Removing the firebase performance plugin seems to resolve the issue; however, I want the automatic tracking provided by the plugin so I'd like to find a solution that allows me to use both firebase and facebook

Ad

Answer

Facebook says their android sdk is not currently compatible with the firebase performance plugin.

https://developers.facebook.com/bugs/2046702775626929/

Ad
source: stackoverflow.com
Ad