Closed cybertheory closed 3 years ago
Thanks for the detailed report @cybertheory. I see couple of observations in your config.
According to the flutterfire documentation for the plugin, the project level build.gradle
is listed to have classpath 'com.google.firebase:firebase-crashlytics-gradle:2.5.1'
, whereas, you have classpath 'com.google.firebase:firebase-crashlytics-gradle:2.6.1'
In your app level build.gradle
, you have apply plugin
entries at top of the file, whereas, in the documentation, it is mentioned to add the same at bottom of the file:
Can you make above changes and try again ?
Also go through this issue to see if any of the solutions mentioned works for you.
Hi @darshankawar, thanks for the quick response! I have just implemented the changes. Unfortunately, it did not work.
I have visited the referenced issue and tried some of the solutions there. None of them worked. :(
I just tried removing the lines
implementation 'com.google.firebase:firebase-analytics:17.0.3' implementation 'com.google.firebase:firebase-crashlytics:17.4.1'
This was an attempt from a potential solution, that did not work either.
Thanks for the details. Can you try the same using plugin's official example to see if you see similar behavior ?
Ok so I got it working! This was completely by fluke and I guess it was an authentication/config error. For future reference: MAKE SURE TO USE THE SAME PACKAGE ID FOR YOUR FIREBASE PROJECT I had been using a different package id on my project. For some other reason, I decided to register a new app with the correct ID. This led to the crashlytics finally reporting!
Glad to know you got it resolved. Going ahead and closing this based on above comment.
Bug report
I have been trying to implement the latest version of the Crashlytics package for flutter. I have been trying to induce test crashes for the past day and upon re-opening... Crashlytics is not reporting to Firebase console. Then through further investigation via the logcat for Crashlytics I found this error that I couldn't find a working solution for:
Steps to reproduce
Steps to reproduce the behavior:
Expected behavior
I expect to not show any error in the log and report the test crash to Firebase Console.
Sample project
App level Build.gradle
Click To Expand
``` def localProperties = new Properties() def localPropertiesFile = rootProject.file('local.properties') if (localPropertiesFile.exists()) { localPropertiesFile.withReader('UTF-8') { reader -> localProperties.load(reader) } } def flutterRoot = localProperties.getProperty('flutter.sdk') if (flutterRoot == null) { throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") } def flutterVersionCode = localProperties.getProperty('flutter.versionCode') if (flutterVersionCode == null) { throw new GradleException("versionCode not found. Define flutter.versionCode in the local.properties file.") } def flutterVersionName = localProperties.getProperty('flutter.versionName') if (flutterVersionName == null) { throw new GradleException("versionName not found. Define flutter.versionName in the local.properties file.") } def keystoreProperties = new Properties() def keystorePropertiesFile = rootProject.file('key.properties') if (keystorePropertiesFile.exists()) { keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) } apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" apply plugin: 'com.android.application' apply plugin: 'com.google.gms.google-services' apply plugin: 'com.google.firebase.crashlytics' android { compileSdkVersion 30 sourceSets { main.java.srcDirs += 'src/main/kotlin' } lintOptions { disable 'InvalidPackage' } defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.pikfarm.pikfarm" minSdkVersion 21 targetSdkVersion 30 versionCode flutterVersionCode.toInteger() versionName flutterVersionName multiDexEnabled true } signingConfigs { release { keyAlias keystoreProperties['keyAlias'] keyPassword keystoreProperties['keyPassword'] storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null storePassword keystoreProperties['storePassword'] } } buildTypes { release { signingConfig signingConfigs.release } } } flutter { source '../..' } dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation 'com.google.firebase:firebase-analytics:17.5.0' implementation 'com.google.android.material:material:1.3.0' implementation "androidx.multidex:multidex:2.0.1" implementation 'com.google.firebase:firebase-messaging:6.0.16' //implementation 'com.facebook.android:facebook-android-sdk:[5,6)' } ```Project Level Build.gradle
Click To Expand
``` buildscript { ext.kotlin_version = '1.3.50' repositories { google() jcenter() // mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:3.5.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath 'com.google.gms:google-services:4.3.8' classpath 'com.google.firebase:firebase-crashlytics-gradle:2.6.1' } } allprojects { repositories { google() jcenter() } } rootProject.buildDir = '../build' subprojects { project.buildDir = "${rootProject.buildDir}/${project.name}" } subprojects { project.evaluationDependsOn(':app') } task clean(type: Delete) { delete rootProject.buildDir } ```Crashlytics Service
Click To Expand
``` import 'package:firebase_crashlytics/firebase_crashlytics.dart'; import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:pikfarm/shared/constants.dart'; class CrashReporting { static FirebaseCrashlytics crash = FirebaseCrashlytics.instance; static void init(BuildContext context) async { if (kDebugMode) { print("we in debug, crashlytics STOP"); // Force disable Crashlytics collection while doing every day development. // Temporarily toggle this to true if you want to test crash reporting in your app. await crash.setCrashlyticsCollectionEnabled(false); if (await crash.checkForUnsentReports()) { await crash.sendUnsentReports(); } } else { if (!crash.isCrashlyticsCollectionEnabled) { // set up the button Widget okButton = FlatButton( child: Text("Allow"), onPressed: () async { await crash.setCrashlyticsCollectionEnabled(true); await crash.setUserIdentifier(Constants.myUserId); Navigator.of(context).pop(); }, ); Widget noButton = FlatButton( child: Text("Deny"), onPressed: () { Navigator.of(context).pop(); }, ); // set up the AlertDialog AlertDialog alert = AlertDialog( title: Text("Enable Crash reporting"), content: Text( <--Redacted--> actions: [okButton, noButton], ); // show the dialog showDialog( context: context, builder: (BuildContext context) { return alert; }, ); } else { print("crashlytics is up"); } // Handle Crashlytics enabled status when not in Debug, // e.g. allow your users to opt-in to crash reporting. } } static void testCrash() { if (crash.isCrashlyticsCollectionEnabled) { // Collection is enabled. crash.crash(); } } } ``` ## Test crash ``` onPressed: () { CrashReporting.testCrash(); Navigator.push( context, MaterialPageRoute( settings: RouteSettings(name: "/cart"), builder: (context) => Cart())); } ```Additional context
Click To Expand
``` My research came across a number of similar issues that didn't have a substantial solution. Many just said the issue went away automatically. The only caveat was that many people were using older versions of the SDK and the errors were worded differently. These same posters claimed that it was an authentication error with Firebase itself. I am at a loss and don't know what else to try. I followed this documentation: https://firebase.flutter.dev/docs/crashlytics/overview https://pub.dev/documentation/firebase_crashlytics/latest/ https://firebase.google.com/docs/crashlytics/ https://firebase.google.com/docs/crashlytics/test-implementation ```Flutter doctor
Click To Expand
``` Doctor summary (to see all details, run flutter doctor -v): [√] Flutter (Channel stable, 2.2.0, on Microsoft Windows [Version 10.0.19042.985], locale en-US) [√] Android toolchain - develop for Android devices (Android SDK version 30.0.3) [√] Chrome - develop for the web [√] Android Studio [√] IntelliJ IDEA Community Edition (version 2020.3) [√] Connected device (3 available) • No issues found! ```Flutter dependencies
Click To Expand
``` Dart SDK 2.13.0 Flutter SDK 2.2.0 pikfarm 1.4.13+12 dependencies: - another_flushbar 1.10.22 [pedantic flutter] - cached_network_image 3.0.0 [flutter flutter_cache_manager octo_image] - cloud_firestore_mocks 0.9.0+1 [flutter cloud_firestore cloud_firestore_platform_interface collection plugin_platform_interface quiver] - cupertino_icons 1.0.3 - firebase_analytics 8.1.0 [firebase_analytics_platform_interface firebase_analytics_web firebase_core flutter meta] - firebase_auth 1.2.0 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta] - firebase_core 1.2.0 [firebase_core_platform_interface firebase_core_web flutter meta] - firebase_crashlytics 2.0.4 [firebase_core firebase_core_platform_interface firebase_crashlytics_platform_interface flutter stack_trace] - firebase_messaging 10.0.0 [firebase_core firebase_core_platform_interface firebase_messaging_platform_interface firebase_messaging_web flutte r meta] - firebase_storage 8.1.0 [firebase_core firebase_core_platform_interface firebase_storage_platform_interface firebase_storage_web flutter] - flappy_search_bar 1.7.2 [flutter async flutter_staggered_grid_view] - flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine] - flutter_local_notifications 6.0.0 [flutter flutter_local_notifications_platform_interface platform timezone] - flutter_masked_text 0.8.0 [flutter] - flutter_money_formatter 0.8.3 [flutter intl] - flutter_rating_bar 4.0.0 [flutter] - flutter_spinkit 5.0.0 [flutter] - flutter_typeahead 3.1.3 [flutter flutter_keyboard_visibility] - geocoder 0.2.1 [meta flutter] - geoflutterfire 3.0.0-nullsafety.4 [flutter cloud_firestore rxdart] - geolocator 7.0.3 [flutter geolocator_platform_interface geolocator_web] - google_maps_flutter 2.0.6 [flutter flutter_plugin_android_lifecycle google_maps_flutter_platform_interface] - google_maps_webservice 0.0.20-nullsafety.5 [http meta json_annotation] - image_cropper 1.4.0 [flutter] - image_picker 0.7.5+3 [flutter flutter_plugin_android_lifecycle image_picker_platform_interface image_picker_for_web] - import_sorter 4.5.1 [args tint yaml] - permission_handler 8.0.0+2 [flutter meta permission_handler_platform_interface] - provider 5.0.0 [collection flutter nested] - shared_preferences 2.0.6 [meta flutter shared_preferences_platform_interface shared_preferences_linux shared_preferences_macos shared_prefere nces_web shared_preferences_windows] - stripe_sdk 5.0.0-nullsafety.0 [flutter http url_launcher mask_text_input_formatter flutter_slidable simple_animations supercharged awesome_ca rd uni_links2 credit_card_validator collection] - time_slider 0.1.0 [flutter] - uri 1.0.0 [matcher quiver] - uuid 3.0.4 [crypto] - webview_flutter 2.0.7 [flutter] dev dependencies: - dependency_validator 3.1.0 [args build_config checked_yaml glob io json_annotation logging package_config path pub_semver pubspec_parse yaml] - flutter_launcher_icons 0.9.0 [args image path yaml] - flutter_native_splash 1.1.8+4 [image meta path xml yaml universal_io] - flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters charcode collection matc her meta source_span stream_channel string_scanner term_glyph typed_data] - test 1.17.4 [analyzer async boolean_selector collection coverage http_multi_server io js node_preamble package_config path pedantic pool shel f shelf_packages_handler shelf_static shelf_web_socket source_span stack_trace stream_channel typed_data web_socket_channel webkit_inspection_p rotocol yaml test_api test_core] dependency overrides: - intl 0.17.0 [clock path] - test_api 0.4.0 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph matcher] transitive dependencies: - _fe_analyzer_shared 22.0.0 [meta] - analyzer 1.6.0 [_fe_analyzer_shared cli_util collection convert crypto glob meta package_config path pub_semver source_span watcher yaml peda ntic] - archive 3.1.2 [crypto path] - args 2.0.0 - async 2.6.1 [meta collection] - awesome_card 1.1.5 [flutter] - boolean_selector 2.1.0 [source_span string_scanner] - build_config 1.0.0 [checked_yaml json_annotation path pubspec_parse yaml] - characters 1.1.0 - charcode 1.2.0 - checked_yaml 2.0.1 [json_annotation source_span yaml] - cli_util 0.3.0 [meta path] - clock 1.1.0 - cloud_firestore 2.2.0 [cloud_firestore_platform_interface cloud_firestore_web firebase_core firebase_core_platform_interface flutter meta] - cloud_firestore_platform_interface 5.1.0 [collection firebase_core flutter meta plugin_platform_interface] - cloud_firestore_web 2.1.0 [cloud_firestore_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js] - collection 1.15.0 - convert 3.0.0 [typed_data] - coverage 1.0.2 [args logging package_config path source_maps stack_trace vm_service] - credit_card_type_detector 2.0.0-nullsafety.0 - credit_card_validator 2.0.0-nullsafety.0 [credit_card_type_detector] - crypto 3.0.1 [collection typed_data] - fake_async 1.2.0 [clock collection] - ffi 1.1.0 - file 6.1.1 [meta path] - firebase 9.0.1 [http http_parser js] - firebase_analytics_platform_interface 2.0.1 [flutter meta] - firebase_analytics_web 0.3.0+1 [firebase firebase_analytics_platform_interface flutter flutter_web_plugins meta] - firebase_auth_platform_interface 4.2.3 [firebase_core flutter meta plugin_platform_interface] - firebase_auth_web 1.1.3 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser intl js met a] - firebase_core_platform_interface 4.0.1 [collection flutter meta plugin_platform_interface] - firebase_core_web 1.1.0 [firebase_core_platform_interface flutter flutter_web_plugins js meta] - firebase_crashlytics_platform_interface 3.0.4 [collection firebase_core flutter meta plugin_platform_interface] - firebase_messaging_platform_interface 3.0.0 [firebase_core flutter meta plugin_platform_interface] - firebase_messaging_web 2.0.0 [firebase_core firebase_core_web firebase_messaging_platform_interface flutter flutter_web_plugins js meta] - firebase_storage_platform_interface 2.1.0 [collection firebase_core flutter meta plugin_platform_interface] - firebase_storage_web 1.1.0 [async firebase_core firebase_core_web firebase_storage_platform_interface flutter flutter_web_plugins http js met a] - flutter_blurhash 0.6.0 [flutter meta pedantic] - flutter_cache_manager 3.0.2 [clock collection file flutter http image path path_provider pedantic rxdart sqflite uuid] - flutter_keyboard_visibility 5.0.2 [meta flutter_keyboard_visibility_platform_interface flutter_keyboard_visibility_web flutter] - flutter_keyboard_visibility_platform_interface 2.0.0 [flutter meta plugin_platform_interface] - flutter_keyboard_visibility_web 2.0.0 [flutter_keyboard_visibility_platform_interface flutter_web_plugins flutter] - flutter_local_notifications_platform_interface 4.0.0 [flutter plugin_platform_interface] - flutter_plugin_android_lifecycle 2.0.2 [flutter] - flutter_slidable 0.6.0 [flutter] - flutter_staggered_grid_view 0.3.4 [flutter] - flutter_web_plugins 0.0.0 [flutter js characters collection meta typed_data vector_math] - frontend_server_client 2.1.0 [async path] - geolocator_platform_interface 2.0.2 [flutter plugin_platform_interface vector_math meta] - geolocator_web 2.0.3 [flutter flutter_web_plugins geolocator_platform_interface] - glob 2.0.1 [async collection file path pedantic string_scanner] - google_maps_flutter_platform_interface 2.0.4 [flutter meta plugin_platform_interface stream_transform collection] - http 0.13.3 [async http_parser meta path pedantic] - http_multi_server 3.0.1 [async] - http_parser 4.0.0 [charcode collection source_span string_scanner typed_data] - image 3.0.2 [archive meta xml] - image_picker_for_web 2.0.0 [image_picker_platform_interface meta flutter flutter_web_plugins] - image_picker_platform_interface 2.1.0 [flutter meta http plugin_platform_interface] - io 1.0.0 [meta path string_scanner] - js 0.6.3 - json_annotation 4.0.1 - logging 1.0.1 - mask_text_input_formatter 2.0.0-nullsafety.2 [flutter] - matcher 0.12.10 [stack_trace] - meta 1.3.0 - mime 1.0.0 - nested 1.0.0 [flutter] - node_preamble 2.0.0 - octo_image 1.0.0+1 [flutter flutter_blurhash] - package_config 2.0.0 [path] - path 1.8.0 - path_provider 2.0.2 [flutter path_provider_platform_interface path_provider_macos path_provider_linux path_provider_windows] - path_provider_linux 2.0.0 [path xdg_directories path_provider_platform_interface flutter] - path_provider_macos 2.0.0 [flutter] - path_provider_platform_interface 2.0.1 [flutter meta platform plugin_platform_interface] - path_provider_windows 2.0.1 [path_provider_platform_interface meta path flutter ffi win32] - pedantic 1.11.0 - permission_handler_platform_interface 3.5.0 [flutter meta plugin_platform_interface] - petitparser 4.1.0 [meta] - platform 3.0.0 - plugin_platform_interface 2.0.0 [meta] - pool 1.5.0 [async stack_trace] - process 4.2.1 [file path platform] - pub_semver 2.0.0 [collection] - pubspec_parse 1.0.0 [checked_yaml collection json_annotation pub_semver yaml] - quiver 3.0.1 [matcher] - rxdart 0.27.0 - shared_preferences_linux 2.0.0 [flutter file meta path path_provider_linux shared_preferences_platform_interface] - shared_preferences_macos 2.0.0 [shared_preferences_platform_interface flutter] - shared_preferences_platform_interface 2.0.0 [flutter] - shared_preferences_web 2.0.0 [shared_preferences_platform_interface flutter flutter_web_plugins meta] - shared_preferences_windows 2.0.0 [shared_preferences_platform_interface flutter file meta path path_provider_platform_interface path_provider _windows] - shelf 1.1.4 [async collection http_parser path stack_trace stream_channel] - shelf_packages_handler 3.0.0 [path shelf shelf_static] - shelf_static 1.0.0 [convert http_parser mime path shelf] - shelf_web_socket 1.0.1 [shelf stream_channel web_socket_channel] - simple_animations 3.1.1 [flutter supercharged pedantic] - sky_engine 0.0.99 - source_map_stack_trace 2.1.0 [path stack_trace source_maps] - source_maps 0.10.10 [source_span] - source_span 1.8.1 [collection path term_glyph] - sqflite 2.0.0+3 [flutter sqflite_common path] - sqflite_common 2.0.0+2 [synchronized path meta] - stack_trace 1.10.0 [path] - stream_channel 2.1.0 [async] - stream_transform 2.0.0 - string_scanner 1.1.0 [charcode source_span] - supercharged 2.0.0 [supercharged_dart flutter] - supercharged_dart 2.0.0 - synchronized 3.0.0 - term_glyph 1.2.0 - test_core 0.3.24 [analyzer async args boolean_selector collection coverage frontend_server_client glob io meta package_config path pedantic p ool source_map_stack_trace source_maps source_span stack_trace stream_channel vm_service yaml matcher test_api] - timezone 0.7.0 [path] - tint 2.0.0 - typed_data 1.3.0 [collection] - uni_links2 0.6.0+2 [uni_links2_platform_interface uni_links_web2 flutter] - uni_links2_platform_interface 1.0.0+2 [plugin_platform_interface flutter] - uni_links_web2 0.1.0+2 [uni_links2_platform_interface flutter flutter_web_plugins] - universal_io 2.0.4 [collection crypto meta typed_data] - url_launcher 6.0.4 [flutter url_launcher_platform_interface url_launcher_linux url_launcher_macos url_launcher_windows url_launcher_web] - url_launcher_linux 2.0.0 [flutter] - url_launcher_macos 2.0.0 [flutter] - url_launcher_platform_interface 2.0.3 [flutter plugin_platform_interface] - url_launcher_web 2.0.0 [url_launcher_platform_interface meta flutter flutter_web_plugins] - url_launcher_windows 2.0.0 [flutter] - vector_math 2.1.0 - vm_service 6.2.0 - watcher 1.0.0 [async path pedantic] - web_socket_channel 2.1.0 [async crypto stream_channel] - webkit_inspection_protocol 1.0.0 [logging] - win32 2.1.1 [ffi] - xdg_directories 0.2.0 [meta path process] - xml 5.1.1 [collection meta petitparser] - yaml 3.1.0 [collection source_span string_scanner] ```