Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Integrating Crashlytics to library project

Tags:

I have a library project (a custom view library project) which doesn't have any Activities/services. I want to integrate Crashlytics SDK to my library. When I try to add it via Crashlytics plugin (the icon in toolbar) for Android Studio, it just stays on "Checking" for "Select a kit to install". The question is how can I add Crashlytics to my Android library project?

Best Regards

like image 248
user2498079 Avatar asked Mar 03 '15 09:03

user2498079


People also ask

Why Crashlytics is integrated with your app?

By linking Firebase and Google Play, you get a richer view into your Android app's health. For example, in the Crashlytics dashboard, you can filter your app's crash reports by Google Play track, which allows you to better focus your dashboard on specific builds.

Is Crashlytics deprecated?

Old versions of your app still using the Fabric Crashlytics SDK will not break once it's deprecated, however they will no longer submit crash reports. But it seems like it will just continue to work as per normal after this date until further notice. Just leave it the way it is.


2 Answers

It can be done, with the help of the parent app that consumes the module.

  • Set up Firebase on the parent using the normal steps.
  • Add this to the build.gradle of the library module.
  implementation 'com.google.firebase:firebase-core:16.0.1'
  implementation 'com.crashlytics.sdk.android:crashlytics:2.9.9'
  • Create a class in the library module with this static variable. public static Crashlytics crash;
  • In the parents Application class, assign Crashlytics.getInstance(); to that variable.
  • The library module can call crash.core.logException(e); anywhere in the library and sent off to the Firebase console - but include a null check in case eg. library test methods are being called without a parent app.
  • Other unhandled exceptions eg throw new RuntimeException("test"); in the library should also show up in the console.
like image 62
g2server Avatar answered Nov 03 '22 16:11

g2server


You need an app module at the moment, even if your intention is to integrate Crashlytics only in your library. If what you only have is the library, there is no reasonable way of doing that, not officially yet at least.

See below for generating the necessary stuff first in the app side and then moving (some of them) towards your library such as the initialization.

When you onboard a kit, Fabric sets up the initialization code inside the base project, not the library. Here's how you'd do it...

like image 45
Kerem Avatar answered Nov 03 '22 14:11

Kerem