I am using this code to track when the app has crashed:
val core = CrashlyticsCore
.Builder()
.listener {
Log.d("***", "Crash happened")
}
.build()
val crashlyticsKit = Crashlytics
.Builder()
.core(core)
.build()
// Initialize Fabric with the debug-location_inactive crashlytics.
Fabric.with(context, crashlyticsKit)
I am testing it with throw NullPointerException()
and with Crashlytics.getInstance().crash()
. None of them calls listener. When the app starts again, this is in the logs:
I/CrashlyticsCore: Initializing Crashlytics 2.6.1.23
I/CrashlyticsInitProvider: CrashlyticsInitProvider initialization successful
D/FirebaseApp: com.google.firebase.crash.FirebaseCrash is not linked. Skipping initialization.
I/CrashlyticsCore: Crashlytics report upload complete: SOME-LETTERS-AND-NUMBERS
What am I doing wrong?
EDIT I used code from How to show a Dialog after crash by using Crashlytics? as a template for mine, but it seems that the API has slightly changed (in this answer, it instantiates as a class, but now it is a listener, see docs)
By default, Firebase Crashlytics is using content provider hack to automatically initialize itself (com.crashlytics.android.CrashlyticsInitProvider
is injected into merged AndroidManifest
).
According to the documentation automatic initialization can be overridden with meta-data
flag:
<manifest>
<application>
<meta-data
android:name="firebase_crashlytics_collection_enabled"
android:value="false" />
</application>
</manifest>
Now calling Fabric.with(context, crashlyticsKit)
will actually initialize sdk and should trigger listener correctly.