Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Leakcanary crashes with Google's Firebase

When processing a leak, I get a java.lang.IllegalStateException: FirebaseApp with name [DEFAULT] doesn't exist. inside my Application.onCreate. From what I understand, this happens because LeakCanary creates my application class without all the Google Play Services stuff and Firebase cannot initialize successfully. Any ideas how to fix this?

Edit: I'm using leakcanary-android:1.4-beta2 and this happens after dumping the heap.

like image 698
DariusL Avatar asked Oct 18 '22 08:10

DariusL


1 Answers

Alternatively you could leave the google play services plugin configuration as suggested by the documentation.

Disable FirebaseInitProvider by adding this to AndroidManifest.xml

<provider
    android:name="com.google.firebase.provider.FirebaseInitProvider"
    android:enabled="false" />

And add this to your Application class

FirebaseOptions options = FirebaseOptions.fromResource(this);
FirebaseApp.initializeApp(this, options);

This way you don't have to configure FirebaseOptions by hand.

like image 66
ne'mi Avatar answered Nov 02 '22 10:11

ne'mi