简体   繁体   中英

Crashlytics / Fabric not reporting crashes on Android

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.

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

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"));

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);

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.

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....

Crashlytics.getInstance().crash(); // it is deprecated 

现在你可以使用,

throw new RuntimeException("This is a crash");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM