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.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
dmestrovic
  • 712
  • 1
  • 5
  • 15

6 Answers6

7

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

FractalBob
  • 3,225
  • 4
  • 29
  • 40
  • 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!! – Octavian Ionel Apr 30 '20 at 15:37
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"));
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);
vallabh
  • 505
  • 6
  • 10
  • 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. – vallabh Jun 12 '18 at 09:40
  • Where should i add these lines? – Tarun Aug 29 '18 at 07:00
  • 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). – vallabh Aug 30 '18 at 07:31
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.

Midhun Vijayakumar
  • 2,927
  • 2
  • 19
  • 23
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....

AllanRibas
  • 678
  • 5
  • 14
0
Crashlytics.getInstance().crash(); // it is deprecated 

Now you can use,

throw new RuntimeException("This is a crash");
Suraj Gupta
  • 879
  • 7
  • 6