Wanted to get a crash report from firebase once the app gets crashed. Is it possible to get debug mode logs separate and production crash log separate in firebase crash?...because its not really clear when we get crash from production or debug test. Also, firebase won't reflect crash report on the console after a crash happens. What should I do to get up to date crash report? Is there another way to get a crash report other than firebase? I have updated the libraries which required for the firebase crashlytics. and Followed tutorial - https://firebase.google.com/docs/crashlytics/get-started#android
-
firebase takes 24h to show the crash reports. – Urvish rana Jan 02 '19 at 06:11
-
1Thanks for your quick replay, But I didn't get crash after 24h.In that case, what should I do? – Meera Potdar Jan 02 '19 at 06:13
-
4@Urvishrana, I think that's not true, in my case, the crashes were updating in 5 mins – letsintegreat Jan 02 '19 at 06:13
-
3yes @Zlytherin usually it reflects within some minuts. – Rumit Patel Jan 02 '19 at 06:14
-
@MeeraPotdar which tutorial you followed? and what have you done so far? kindly update question. – Rumit Patel Jan 02 '19 at 06:15
-
@Zlytherin when I tested back it took 24hours – Urvish rana Jan 02 '19 at 06:16
-
Which _Firebase Crash Reporting SDK_ are you using? – Piyush Jan 02 '19 at 06:16
-
@Rumit Patel, I hadn't followed any specific tutorial yet. – Meera Potdar Jan 02 '19 at 06:19
-
1@MeeraPotdar follow this https://firebase.google.com/docs/crashlytics/get-started#android – Urvish rana Jan 02 '19 at 06:21
-
@MeeraPotdar, [edit your question](https://stackoverflow.com/posts/54001966/edit) and post both the `build.gradle` files – letsintegreat Jan 02 '19 at 06:22
-
Please check shared build.gradles https://www.dropbox.com/s/8b0sukk45hckf3u/build.gradle?dl=0 https://www.dropbox.com/s/wonj78k8yt9pr9i/build.gradle_project?dl=0 – Meera Potdar Jan 02 '19 at 06:33
8 Answers
Is it possible to get debug mode logs separate and production crash log separate in firebase crash?
It's common practice or perhaps even recommended that you create a separate project for testing and production. Download and place the google-services.json
in your build flavor folder
~/app/src/release/google-services.json
~/app/src/debug/google-services.json
Even if you are only having a single Firebase project for test and production, you can filter your logs by the application id if you're setting up a project id suffix for the development build flavor:
~/app/build.gradle
buildTypes {
release {
}
debug {
applicationIdSuffix '.debug'
versionNameSuffix '-dbg'
}
}
Here you can see the different flavors being available in Crashlytics
Also, firebase won't reflect crash report on the console after a crash happens.
First time that you set up crashlytics it might take some time before the data shows up in the dashboard. But if it's been over 24 hours, it's likely that it's not properly set up. Try to explicitly trigger a crash to make sure that it works fine.
Button crashButton = new Button(this);
crashButton.setText("Crash!");
crashButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Crashlytics.getInstance().crash(); // Force a crash
}
});
Is there another way to get a crash report other than firebase?
Yes you can have more than one crash reporting tool if you have the need. You can perhaps create a wrapper class for crash reporting where you abstract the call to Crashlytics and you can add or change the underlying reporting platform there.

- 2,916
- 1
- 13
- 34
-
1Thank you for your guidance. I would like to implement your solution and let you know If any help required. – Meera Potdar Jan 02 '19 at 07:27
-
Can you please explain to me How to make multiple google-services.json files of the same project? I made two flavors internal and production, So I need to create two google-services.json files according to application Ids. Do I need to create two different projects on firebase? – Meera Potdar Jan 03 '19 at 07:12
-
You get one `google-services.json` for each app that you add to Firebase. So the same way you added the first app to Firebase, you repeat for the flavor with the `applicationIdSuffix`. It's the same procedure whether you are having two separate Firebase projects or if you're adding both flavors to the same project. – Dennis Alund Jan 03 '19 at 08:07
-
I create a new project on firebase to get a new google-service.json file. – Meera Potdar Jan 04 '19 at 04:32
-
Yes, please see [the documentation](https://firebase.google.com/docs/projects/multiprojects#support_multiple_environments_in_your_android_application) for how to set it up. – Dennis Alund Jan 07 '19 at 07:52
-
Is this outdated? Using an applicationIdSuffix for my debug build I am finding that nothing is uploaded to Google Crashlytics console. The release build without the suffix works as expected with reports appearing in the console almost instantly. – Thomas Clowes May 04 '20 at 09:43
-
Do you have different projects for develop/production or report to same Firebase project? Have you checked the app switcher/filter for the reports? Everything else works well for your debug build? – Dennis Alund May 05 '20 at 00:25
Upgrade SDK
After making the relevant settings for the migration to the new SDK, it is important to avoid the following error:
Attempting to send crash report at time of crash.
This can be caused by forcing a crash (without a button listen in my case) before FirebaseCrashlytics send the reports, that is, the Crashlytics Reports Endpoint upload is completed.
Test implementation
Enable Crashlytics debug logging
$ adb devices
$ adb shell setprop log.tag.FirebaseCrashlytics DEBUG
$ adb logcat -s FirebaseCrashlytics
1) First step: DONT force a crash and run the app. Observing how in the Crashlyticis logcat it is initialized correctly.
...
FirebaseCrashlytics: Update app request ID: 1d62cb...
FirebaseCrashlytics: Result was 204.
Crashlytics Reports Endpoint upload complete
2) Step Two: Force a crash (with a button or directly).
MainActivity.kt
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
setupCrashlytics()
...
}
private fun setupCrashlytics() {
throw RuntimeException("Test crash") //TODO: Clean
}
Note: The only thing necessary to generate a report is this code in addition to the dependencies. Additionally you can login custom keys with FirebaseCrashlytics.getInstance()
.
Then run the app and check the following:
FirebaseCrashlytics: Crashlytics completed exception processing. Invoking default exception handler.
FirebaseCrashlytics: Attempting to send crash report at time of crash...
At this point the exception process is logged on the Firebase server but the reports have not yet been sent to the console, that is, the upload is incomplete.
3) Finally, we clean or comment on the crash crash
private fun setupCrashlytics() {
//throw RuntimeException("Test crash")
}
Run app and let's check:
Attempting to send 1 report(s)
FirebaseCrashlytics: Settings result was: 200
FirebaseCrashlytics: Adding single file 5EDA9D7....cls to report 5EDA9D7...
FirebaseCrashlytics: Sending report to: https://reports.crashlytics.com/spi/v1/platforms/android/apps/.../reports
FirebaseCrashlytics: Crashlytics Reports Endpoint upload complete: 5EDABB42 ...
This guarantees that the report reached the console.
GL

- 22,105
- 4
- 57
- 62
Firebase will not differentiate between debug and production versions logs/crashes in crashlytics if you have set auto collection of logs. You can use a logging library to only send logs and crashes if the app build.gradle has debug:fasle i.e. production. You can look at the Timber logging library which has a great example of adding crash reporting. https://github.com/JakeWharton/timber
You have to disable the auto initialization of crashlytics in manifest to have control when crashes are sent to firebase
<meta-data
android:name="firebase_crashlytics_collection_enabled"
android:value="false" />
Then in your Application class's onCreate
you check if BuildConfig.DEBUG
is true you will not initialize crashlaytics so your debug logs and exceptions will not go to firebase, resulting in only production crashes.
For timber when you want to put logs and crashes to firebase you can use this Tree:
/**
* {@link Timber.Tree} using {@link Crashlytics} as crash reporting
*/
private static class CrashReportingTree extends Timber.Tree {
CrashReportingTree(Context context) {
CrashlyticsCore core = new CrashlyticsCore.Builder()
.disabled(BuildConfig.DEBUG)
.build();
Fabric.with(context, new Crashlytics.Builder().core(core).build());
}
@Override
protected void log(int priority, String tag, @NonNull String message, Throwable t) {
// don't report log to Crashlytics if priority is Verbose or Debug
if (priority == Log.VERBOSE || priority == Log.DEBUG) {
return;
}
Crashlytics.log(priority, tag, message);
if (t != null) {
if (priority == Log.ERROR) {
Crashlytics.logException(t);
}
}
}
}
For debug mode you should not send crashes to firebase as you can check the debug logs locally.

- 3,461
- 1
- 16
- 38
-
Thank you so much for your brief description. I would like to check first, It is working properly for me or not. Let you know If I need any help. – Meera Potdar Jan 02 '19 at 07:22
Please remove fabric.properties and remove all fabric related lines and files

- 1,132
- 13
- 17
I solve this issue thanks to AllwinJohnson solution in: https://github.com/firebase/firebase-android-sdk/issues/1944
By Adding: FirebaseCrashlytics.getInstance() in my onCreate in my Application class

- 809
- 1
- 19
- 25
The issue for me was the emulator itself. Fixing the date and time on the emulator did it for me as it was resulting in a CertificateNotYetValidException
.

- 2,080
- 1
- 9
- 12
This will help if you moved from fabric SDK to Firebase Crashlytics. Add the below line in your OnCreate() run the app and check your firebase crashlytics dashboard.
FirebaseCrashlytics.getInstance().sendUnsentReports();

- 51
- 3
In my case, I made the silly mistake of doing:
FirebaseCrashlytics.getInstance().setUserId(uid);
where uid
was still null.

- 512
- 6
- 18