Crashlytics not showing the logs - android

In my android project I'm using Crashlytics to get the app crash reports.I have also added the logs to see it in my dashboard.For adding logs I've used
Crashlytics.log (Log.ERROR, TAG, message);
So when I run the app for testing,and open the activity where I've added the Crashlytics log statements ,the logs were generated for the first time .I can see them on the dashboard. But when I again open the same activity ,I'm not able to see the new logs generated . I read here that if the logs are not seen on the dashboard then restart the app.I did that ,but still couldn't see the logs on the dashboard,my dashboard only shows the logs which were generated for the first time.I also tried testing my app on different device but it still doesn't show on the dashboard.Can somebody please help me in solving this issue .Why am I not able to see all non-fatal logs on my dashboard?

IF this doesn't produce errors you have to wait for logs registered on your dashboard in free account

Mike from Firebase here.
Crashlytics.log (Log.ERROR, TAG, message); will only be displayed if there is also a non-fatal - Crashlytics.logException(e); or fatal exception. We prioritize capturing exceptions (fatal or non-fatal) over logs so if you log the value immediately before the exception, depending on the size of the log, it may not be recorded. This is because we think capturing the exception is more important than the log.

Related

Using AppCenter, am I able to add user data to a unhandled crash report?

We have a Xamarin.Android application for a client which is experiencing crashes on the field. They aren't reproducible when going through testing but we are able to handle the crash and add information like the user data to it. But when a crash that isn't handled happens, we just get an obscure log. I've been asked to try and get some user data into the unhandled crash to understand which user has caused it.
So, basically, am I able to add data to the log of an unhandled crash using AppCenters Library?
I've done some research and just found...
AndroidEnvironment.UnhandledExceptionRaiser += (sender, args) =>
{
TraceWriter.WriteTrace(args.Exception);
args.Handled = true;
};
This seems to be an overall exception handler. I read it would be just used to get more info about the crash but can't handle it there as the Delvik machine on the device is already crashing. Is this something I could use to pass in more data to a crash?
You can add one binary and one text file to the crash report using Crashes.GetErrorAttachments. The file must be smaller than 7MB. There is more information available in the AppCenter Crashes documentation.
You can also set the user id in the AppCenter SDK using AppCenter.SetUserId so you can tell which user generated the crash report.

crashlytics custom crash reporting not showing on Firebase Console

so I'm using this tutorial https://firebase.google.com/docs/crashlytics/customize-crash-reports to enable crashlytics crash report in my Android App. I noticed that Custom Crashes never appears on my Firebase Console using this code:
Crashlytics.log(Log.DEBUG, "tag", "message");
After setting my UserIdentifier.
But when I tried Forcing a crash like this:
Crashlytics.getInstance().crash(); // Force a crash
it appears on my Dashboard. So why is my Custom Crash missing.
When I switched back to custom logging, It never works. I also tried using LogException, that didn't work as well.
Crashlytics.log(Log.ASSERT, TAG, Log.getStackTraceString(e));
Crashlytics.logException(e);
Please note that It's Firebase console I'm using.
Mike from Firebase here.
Crashlytics.log(Log.DEBUG, "tag", "message"); will log information into a crash, but the logs are only sent and processed if a crash or non-fatal exception happens in the same session of the app.
Writing the log is done async, and we focus on capturing crashes or non-fatal exceptions over writing the log to disk. If the log happens just before a crash or non-fatal as in this example:
Crashlytics.log(Log.ASSERT, TAG, Log.getStackTraceString(e));
Crashlytics.logException(e);
It's possible we didn't have time to write the log before the exception happened. In that case, we'd prioritize capturing the exception believing that getting the exception or crash is more important then a log.

How to send Crashlytics log

I am using Crashlytics (now known as Fabric) in my app.
It works well when the app crashes. I can find the issue on the dashboard.
I am trying to use the logging. Something like:
Crashlytics.log(Log.WARN,MYTAG,"Error message");
I am not able to send this log in the dashboard. I have just tried to add something like:
Crashlytics.logException(new RuntimeException("Fake exception"));
but it doesn't send the log.
Can Crashlytics send the log?
You are sending the Log properly. But see what Official doc says Logging Caught Exceptions
All logged exceptions will appear as "non-fatal" issues in the Crashlytics dashboard.
To reduce your users' network traffic, Crashlytics batches logged exceptions together and sends them the next time the app launches. If you don't see logged exceptions in your Crashlytics web dashboard, try restarting your app!
In Android, send a custom crash by using
Crashlytics.logException(new RuntimeException("Fake exception"));
Then restart your application
In Crashlytics, select the Non-Fatals
On newer versions of Crashlytics, you need to use these functions:
FirebaseCrashlytics.getInstance().log("Your message goes here")
FirebaseCrashlytics.getInstance().recordException(RuntimeException("Your message goes here"))
Edit:
As #Peter mentioned in the comments, using log alone will not work and you have to use recordException function to bundle your log message along with the exception

Trouble with logging my data with crashlytics

I'm trying to get logs with some service data with Crashlytics in my android application. But I don't see my logs in dashboard.
I used this:
String myLog = getServiceData(); //myLog is not null and non-empty
CrashLytics.log(myLog);
and this:
String myLog = getServiceData(); //myLog is not null and non-empty
CrashLytics.log(Log.Error, getString(R.string.app_name), myLog);
I tried to generate exception in my application and handle it, but have no results:
try {
int a = 0;
a = 1/a;
}
catch (Exception e) {
CrashLytics.log(myLog);
}
Also I read on Crashlytics log not sent I need to initialize crashlytics before log data. I put Crashlytics.start(this) in onStart() event of my Activity but didn't see my logs in dashboard again. At last I tried to put Crashlitycs.start(this) directly before logging my data, but still have no logs in dashboard.
Plase, tell me what I do wrong and how to get my custom logs in Crashlytics dashboard?
I had a similar situation. With some experimenting, I was able to deduce the rules to Crashlytics' behavior.
I'm sharing my learnings here so (hopefully) others don't have to go through the arduous and time-consuming process that I did to figure it out.
Crashlytics will only upload a crash report "to the dashboard" immediately if a fatal exception occurs. In other words, when your app crashes. And nothing shows in the dashboard unless and until a crash report is uploaded.
If you log a non-fatal exception, using CrashLytics.logException(e), a crash report will not be uploaded till the next time your app is restarted. So you will not see the exception in the Crashlytics dashboard till an app restart.
You can tell when an upload occurs because you'll see this sort of message in LogCat:
07-17 19:30:41.477 18815-18906/com.foo.bar I/Crashlytics﹕ Crashlytics report upload complete: 55A9BA0C01D7-0001-462D-B8B4C49333333.cls
A Crashlytics log message must be associated with a fatal or non-fatal exception to show up in the dashboard.
Furthermore, log messages that aren't associated with an exception do not survive app restart.
So, if you do something like log a few messages, then restart the app, then the app throws an exception, or it logs a non-fatal exception using Crashlytics.logException(), the log messages will be lost. They will not show up in the dashboard.
If you want to log some messages without a fatal exception, use one or more Crashlytics.log() statements followed by Crashlytics.logException().
To verify that it works, have the code run, then restart the app. In the dashboard, you should see the logs associated with the issue created for the non-fatal exception. In the wild, you'll just have to trust your users restart the app with some regularity.
On the Fabric/Crashlytics dashboard, you'll need to select All Events or (if you want to see just your logging calls) Non-Fatals.
according to Crashlytics knowledgebase:
Logged messages are associated with your crash data and are visible in
the Crashlytics dashboard if you look at the specific crash itself.
And from my experience this seems true. However I am unsure as to what determines which logging is associated with a crash report. Perhaps a time window (time around crash) or a limited number of logs (before the crash) is associated with the crash report?
However Crashlytics knowledgebase does say that exceptions can be logged:
All logged exceptions will appear as "non-fatal" issues in the
Crashlytics dashboard.
So if you changed your try/catch to:
try {
int a = 0;
a = 1/a;
}
catch (Exception e) {
CrashLytics.logException(e);
}
then it should show up in the Crashlytics dashboard.
This is an old question but since I was having the same problem today, I figured I should post my solution (it's in Kotlin though).
With Crashlytics now a part of Google's Firebase offering, it initializes behind the scenes, so a solution I wrote a few years ago had to be updated to this:
Implement some kind of log caching, First In First Out. I put one together based on cache-lite.
Put this function in YourApplicationClass that extends Application:
fun setExceptionHandler() {
val defaultExceptionHandler = Thread.getDefaultUncaughtExceptionHandler()
Thread.setDefaultUncaughtExceptionHandler { thread, ex ->
Crashlytics.log(cacheLoggingTree.getAll().joinToString("++"))
Crashlytics.logException(ex)
defaultExceptionHandler.uncaughtException(thread, ex)
}
}
Then you call the function from the end of your onCreate function in your MainActivity:
(application as YourApplicationClass).setExceptionHandler()
With that, any exceptions that get thrown will first post the most recent log entries, then log the exception. You probably want to be cautious with how many lines you cache though, lest you overload the system.
Also, I used ++ as a flag to manually replace with carriage returns when you download the log, since the \n I had gets stripped in the upload process.
Instead of catching the exception and logging it, you can instead use RuntimeExceptions:
throw new RuntimeException("Test crash");
Android Studio will not require you to catch these, thus having the app terminate and upload the report immediately.

GoogleJSONResponseException

I tried to start using Google Cloud Console and followed after the Google IO tutorial for Geek Serendipity http://www.youtube.com/watch?v=v5u_Owtbfew. I followed all the steps of the tutorial, however, I get an error every time I try to send a request to server. Neither logcat, nor Eclipse console gave any errors, however, I see a toast in the application that says
com.google.apiclient.apis.json.GoogleJSONResponseException:503 Service unavailable... "reason": backend error.
However, in google appengine logs there are no recent error.
Has anyone faced same problem?
I would suggest that you ensure the following:
1) Check that you have set PROJECT_ID correctly in the Consts.java
2) You should definitely see the same message in LogCat. Check this answer to get your LogCat working:
Android debugging on device - LogCat doesn't work!
Once LogCat works, you should see the same Exception there, along with another exception such as SocketTimeoutException, or something else that will give you an idea of what went wrong.

Categories

Resources