Crashlytics / Fabric not reporting crashes on Android
Asked Answered
F

6

27

I have some problems with Fabric/Crashlytics.

I'm using Android Studio 1.3.2

Here is my build.gradle

buildscript {
    repositories {
        jcenter()
        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
    jcenter()
    maven { url 'https://maven.fabric.io/public' }
}

android {
...
}

dependencies {
    ...
    compile('com.crashlytics.sdk.android:crashlytics:2.5.2@aar') {
        transitive = true;
    }
}

I added api key in manifest (I added meta-data com.crashlytics.ApiKey, as well as io.fabric.ApiKey).

I'm starting Fabric in Application class

Fabric.with(this, new Crashlytics());

The problem is that Beta is working (I can share, update, open app), Answers is working (Sessions are listed and everything), I can even log exception with

Crashlytics.logException("Test");

And non-fatal crashes will be added to Fabric dashboard.

But for some reason, no "fatal" crashes are reported and sent to Fabric. Can someone please help me? What could be the reason? What am I doing wrong?

Btw - this started happening after update from Crashlytics to Fabric. I reinstalled plugin, deleted app and added it again, tried without plugin for Android Studio.

Frightened answered 25/9, 2015 at 17:59 Comment(3)
Did you add android:name=".Application" to your manifest file?Switchblade
I had it in manifest. Don't know exactly when, but it just started working at some point. Maybe some update, or something. Anyway, it's good now. :)Frightened
Sometimes it is slow. The reports appear only after few minutes, say 5 minutes.Astrogate
S
7

Make sure you're NOT setting a default uncaught exception handler (Thread.setDefaultUncaughtExceptionHandler). This was the problem I had.

Sabah answered 24/9, 2019 at 5:0 Comment(1)
This solved my issue. I have no idea why, but in our code we had this Thread.setDefaultUncaughtExceptionHandler which was causing the issue. Thanks, cheers!!Heid
B
6

Try add it to your Application class:

Fabric.with(this, new Crashlytics());

For test crash report use:

Crashlytics.getInstance().crash();

For report non-fatals use:

Crashlytics.log("Your log");
Crashlytics.logException(new Throwable("This your not-fatal name"));
Bohun answered 16/6, 2016 at 6:55 Comment(5)
Is it necessary to add this in Application class? Or will it even work, if I add the same in Activity class?Respecting
this will be work. I recommend add to Activity which has <category android:name="android.intent.category.LAUNCHER" />Heterogamete
it seems that Crashlytics reports crashes only when my app is connected to android studio. Why so?Neediness
same problem what is solutionTameika
You should also remove apply plugin: 'io.fabric' as I was getting Crashlytics found an invalid API key: null.Cyrille
E
5

As of now you need to update the fabric api to latest 2.9.3 for android and in you main file you need to add this in last of on create() method

final Fabric fabric = new Fabric.Builder(this)
            .kits(new Crashlytics())
            .debuggable(true)
            .build();
Fabric.with(fabric);
Etiquette answered 5/6, 2018 at 12:57 Comment(3)
They have remove the new Answers() and added by default in fabric.Removed identifiers collected that were used for Mobile App Conversion Tracking. If you're using Twitter's Mobile App Conversion Tracking from Answers, do not update to this version. We highly encourage to you explore other mobile measurement partners as Answers won't be a tracking partner after June 30, 2018. Once you use another provider, you can update the Fabric SDKs.Etiquette
Where should i add these lines?Sibyl
you have to add this in your main file means MyApplication.java or you can add this in the activity or fragment you are using the twitter(basically login/Registration activity).Etiquette
C
3

I had a slightly different problem. My Crashlytics stopped logging crashes suddenly after adding Answers dependency to my Project.

 compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
        transitive = true;
    }
 compile('com.crashlytics.sdk.android:answers:1.3.10@aar') {
        transitive = true;
    }

The solution was just to remove the Answers dependency. You don't need it since it is already there in crashlytics pacakge com.crashlytics.android.answers.* .

May be this will be helpful for some users.

Consensus answered 19/11, 2016 at 10:37 Comment(0)
Z
0

build.gradle Project :AppName

    buildscript {
    ext.kotlin_version = '1.3.31'
    repositories {
        google()
        jcenter()
        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.2'
        classpath 'com.google.gms:google-services:4.2.0'
        classpath 'io.fabric.tools:gradle:1.31.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}



allprojects {
    repositories {
        google()
        jcenter()
        maven { url 'https://maven.google.com/' }
        maven { url 'https://maven.fabric.io/public' }
        maven { url "https://jitpack.io" }

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

build.gradle Module :app

        apply plugin: 'io.fabric'
        implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
        implementation 'com.crashlytics.sdk.android:answers:1.4.7'

Add this to AndroidManifest.xml

       <meta-data
            android:name="io.fabric.ApiKey"
            android:value="MyFabricApiKey" />
        <meta-data 
            android:name="firebase_crashlytics_collection_enabled" 
            android:value="true" />

After use

              val core = CrashlyticsCore.Builder().build()
                  Fabric.with(Fabric.Builder(this)
                    .kits(Crashlytics.Builder().core(core).build())
                    .initializationCallback(object: InitializationCallback<Fabric> {
                        override fun success(p0: Fabric?) {
                            LogClass().log("Fabric","$p0")
                        }
                        override fun failure(p0: Exception?) {
                            LogClass().log("Exception","$p0")
                        }
                    })
                    .build()
                )
                Fabric.with(this, Answers())

It works, Show the CRASH in both, Firebase and Fabric panel. thanks....

Zoes answered 24/2, 2019 at 20:2 Comment(0)
D
0
Crashlytics.getInstance().crash(); // it is deprecated 

Now you can use,

throw new RuntimeException("This is a crash");
Delapaz answered 6/7, 2021 at 6:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.