Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Crashlyitics not appearing in Firebase

My Crashlytics data is not appearing in the Firebase Crashlytics view. It does show "Crash-free statistics" as being 75%, so it appears to be recording some data. I also see the crashes appearing instantly both in Fabric and in the old Firebase Crash Reporting interface, as well as in the DebugView as general events but nothing in the Issues section of the Crashlytics page. I thought that perhaps my Fabric project had not been linked to my Firebase project, but when I tried doing it manually using this link https://www.fabric.io/firebase_migration/apps it tells me the projects are already linked, specifically it says Project already contains a linked app with that bundle ID and platform. Every time I open my app in Android studio I immediately run the command adb shell setprop debug.firebase.analytics.app ie.moses.keepitlocal so that my events will appear in the DebugView, perhaps this could be affecting it, but I doubt it.

Here is my project build.gradle file:

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

    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.4'
        classpath 'com.google.gms:google-services:3.3.0'
        classpath 'io.fabric.tools:gradle:1.25.4'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven {
            url 'https://maven.google.com/'
        }

    }
}

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

and this is the build.gradle for my specific app module

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

def supportLibraryVersion = '27.1.1'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "ie.moses.keepitlocal"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 5
        versionName "0.3.1-alpha"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        debug {
            buildConfigField 'boolean', 'CRASHLYTICS', 'true'
        }

        release {
            buildConfigField 'boolean', 'CRASHLYTICS', 'true'
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        if (details.requested.group == 'com.android.support') {
            // Used to prevent conflicting versions of Android support library
            // contained in other dependencies (e.g. all the firebase dependencies)
            details.useVersion supportLibraryVersion
        }
    }
}

dependencies {
    implementation files('libs/YouTubeAndroidPlayerApi.jar')
    implementation "com.android.support:appcompat-v7:$supportLibraryVersion"
    implementation "com.android.support:recyclerview-v7:$supportLibraryVersion"
    implementation "com.android.support:cardview-v7:$supportLibraryVersion"
    implementation 'com.google.firebase:firebase-core:16.0.3'
    implementation 'com.google.firebase:firebase-database:16.0.1'
    implementation 'com.google.firebase:firebase-auth:16.0.3'
    implementation 'com.google.firebase:firebase-crash:16.2.0'
    implementation 'com.crashlytics.sdk.android:crashlytics:2.9.5'
    implementation 'com.jakewharton:butterknife:8.8.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
    implementation 'com.github.bumptech.glide:glide:4.7.1'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'
    implementation 'com.google.guava:guava:26.0-android'
}

apply plugin: 'com.google.gms.google-services'

I am using a Button to force a crash with the following code (as I mentioned, these crashes appear almost immediately in Fabric and in the old Crash Reporting interface which has been deprecated and will be removed in 2 days!). Here is the code for the crash button:

Button crashButton = new Button(this);
        crashButton.setText("Crash!");
        crashButton.setOnClickListener(view -> {
            throw new IllegalStateException("you hit the crash button!");
        });
        addContentView(crashButton, new ViewGroup.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));

EDIT

I have just noticed that on the firebase transition status page it says "0/1 APP LINKED" and "NO PROJECTS YET".

enter image description here

I also need to reinstall the Crashlytics library from the Fabric plugin every time I open Android studio. The dependencies already exist in my gradle file but the plugin does not seem to recognise them.

EDIT

I am now trying to unlink fabric and firebase so I can try linking them again from fresh. I came across this question Unlink an existing firebase app?, but fabric is not even listed as an integration in my project.

like image 422
Moses Avatar asked Sep 07 '18 07:09

Moses


3 Answers

Forget Fabric, it's not required. Just follow instructions in your Firebase console and Firebase documentation: https://firebase.google.com/docs/crashlytics/get-started#android

Don't mess with Fabric console, you should completly remove any calls to Fabric console and configure your project from scratch as Firebase doc says. As soon as you run app correctly configured, you will see Crashlytics panel in your Firebase console

like image 185
user1209216 Avatar answered Sep 19 '22 10:09

user1209216


The only solution I could find was as follows (I am including all steps exactly as I carried them out even if they may not be relevant):

  1. I exported my realtime database to JSON and made a copy of my database rules.
  2. I deleted my app from the Firebase project.
  3. I deleted the Firebase project.
  4. I deleted my project from Fabric.
  5. I removed all references to Fabric, Crashlytics and the old Firebase Crash Reporting library from my project, this consisted of removing the dependencies from both my build.gradle files and deleting the fabric.properties file.
  6. I ran gradlew.bat clean (I'm on Windows) on my project from the command line.
  7. I did a Ctrl+Shift+F (search all project files) for the words fabric and crash just to make sure there was absolutely no remaining references to Fabric, Crashlytics or the deprecated Crash Reporting library (which was still a dependency in my build.gradle without me realising it because Firebase assistant tool added that as the crash reporting dependency when I first tried to get this working and then immediately told me it was deprecated :/ ).
  8. I searched in File Explorer on windows for any files referencing "Fabric" or "Crash" (there weren't any).
  9. I created a new project on Firebase.
  10. I imported my realtime database from the previously exported JSON file and copy/pasted back in my rules.
  11. I recreated my one test user account (thankfully the app is not yet in production :p).
  12. I reenabled analytics (although this was simply a matter of going to the Analytics tab and seeing that it was already enabled as I still had the dependency in my build.gradle for my app module).
  13. I went to the Crashlytics tab and saw the original screen explaining how to enable Crashlytics. This time however I did not create the project on Fabric or install the Fabric plugin, I only copied in the Fabric dependencies as I think @jake was suggesting, these can be found here https://firebase.google.com/docs/crashlytics/get-started?authuser=0.
  14. I then tried to produce a crash using the method described here https://firebase.google.com/docs/crashlytics/force-a-crash?authuser=0.
  15. And then voilà! The crash appeared immediately in the Crashlytics tab of Firebase. No Fabric project, no Fabric plugin, just the dependencies.

This method had the added benefit of allowing me to be rid of extra databases and user properties I did not want (which Firebase does not currently allow you to remove once you create them >:( ), but this method obviously may not be feasible for anyone who already has a lot invested in their Firebase project and cannot simply start over. Luckily for me this was not too much of a pain.

like image 21
Moses Avatar answered Sep 20 '22 10:09

Moses


add apply plugin: 'com.google.firebase.crashlytics' in app module and dependencies {

    classpath 'com.google.firebase:firebase-crashlytics-gradle:2.1.1'
    classpath 'com.google.gms:google-services:4.3.3'
} in project module 
like image 36
jj1 Avatar answered Sep 22 '22 10:09

jj1