Firebase crashlytics still pending flutter

Viewed 475

I want to track my flutter Android/IOS crashes in firebase crashlytics , but there is a problem with tracking the first crash on the app and it's still listening to the first crash.

in pubspec.yaml

firebase_crashlytics:
firebase_analytics:
firebase_core: ^1.7.0

in app build.gradle

apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'io.fabric'

in build.gradle

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

    dependencies {
        classpath 'com.google.gms:google-services:4.3.0'
        classpath 'io.fabric.tools:gradle:1.26.1'
        classpath 'com.android.tools.build:gradle:4.1.0'
    }
}

and in the flutter main.dart :

WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();
  await FirebaseCrashlytics.instance
      .setCrashlyticsCollectionEnabled(true);
  FirebaseCrashlytics.instance.setUserIdentifier("51");
  FlutterError.onError = FirebaseCrashlytics.instance.recordFlutterError;
  FirebaseCrashlytics.instance.crash();

I even tried android native example crash throw new RuntimeExeption("test Firebase crash"); but firebase is still listening for the first app crash.

UPDATE

Firebase Crashlytics page is just like bellow after 48 hours

pending image

3 Answers

Try to filter Non-Fatal errors because the flutter part of the application generates Non-Fatal errors.

Go to firebase console -> crashlytics -> filters -> then choose ->

enter image description here

Here is my dependencies:

dependencies {
        classpath 'com.android.tools.build:gradle:4.1.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.4'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.5.0'

    }

and implementations

dependencies {
    ...

    implementation 'com.google.firebase:firebase-messaging:21.0.1'
    implementation 'com.google.firebase:firebase-crashlytics:17.3.1'
    ...
}
Firebase.initializeApp().then((_) async {

      //enable Crashlytics only when app in release & production
      await FirebaseCrashlytics.instance.setCrashlyticsCollectionEnabled(!kDebugMode);

      //another code here

}

Change !kDebugMode to true if you want to always catch any crash.

I think you can use this line in your code .because of this line I think you can't get the crash report. I'm facing the same issue ..and below code is working perfectly fine

implementation 'com.google.firebase:firebase-crashlytics:17.3.1'

use this code in app.build.gradle

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.billingclient:billing:3.0.2'
    implementation platform('com.google.firebase:firebase-bom:29.0.4')
    implementation 'com.google.firebase:firebase-analytics'
}
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'com.google.gms.google-services'

in Android.build.gradle

  dependencies {
        classpath 'com.android.tools.build:gradle:4.1.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.1'
        classpath 'com.google.gms:google-services:4.3.5'
    }

in you main.dart use this code

Future main() async{
            WidgetsFlutterBinding.ensureInitialized();
            await Firebase.initializeApp();
            
            FlutterError.onError = FirebaseCrashlytics.instance.recordFlutterError;
   runApp(
  
      MyApp(),
    
  );
}

and I put this line to crash the app in Splash init function .you can use this line where you find suitable

  FirebaseCrashlytics.instance.crash();
Related