2021 Android Guide: Firebase Crashlytics - custom crash reporting

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everybody and welcome back thanks for tuning in to another episode here in the series my name is dominic and i'm the host of the android factory the last episode we went ahead and added in the crashlytics dependencies and got everything up and running here so that we have our little crashlytics dashboard up and running uh we had just thrown a particular error for firebase here on click of this particular any of these characters here and we ended up saying that in the last episode we're going to go ahead and try to log or show you how to log some non-fatals and then we can even have some log statements involved in our crash reporting so that we can go ahead and continue to just pinpoint certain you know issues and stuff like that so as you can see here in the logs of a particular crash when you select it there is a screen view here and unfortunately it actually just works uh logging your activity here the name of your activity so kind of helpful if you have one to one ratio between your screens and your activities however we do not we actually have a single activity that has multiple fragments again following that jetpack navigation architecture so this kind of loses its value here because we don't know exactly where in the nav graph activity we are but point being there are certain things that already get logged for you inside of the crashlytics tooling and we can either augment that or add to it uh you know following their documentation so quickly flipping over to the documentation here i will link this in the description no problem uh but we can very easily just get an instance of our crashlytics and then we can set some custom keys here these could be helpful for a variety of different reasons as you're kind of maybe going through the flow in your app and you want to log certain things it could be helpful you know there's a way to kind of log multiple things at once which is just great and then otherwise here we have the ability to log with the log function particular information that will show up here inside of this log tab in the crashlytics recording and then there are some other things here where we can set uh an identifier for a user so you know if there were to be an authentication flow in your application and once they sign in you get a unique id from your backend or your service or the rest of your product uh you can very easily set that id here and then that will actually come up in the crash reporting as well and then there is even a way to basically record non-fatal exceptions with with just the record exception function that exists there and then that will actually trigger um the well we gotta go back but that would trigger uh an event type here of a non-fatal and then you can filter by them or just the actual hard crashes here so let's go ahead and jump right into it so previously we threw an exception here in this list fragment to crash the app but instead what we can go ahead and do here is let's get our instance of the firebase crashlytics and then let's say record exception here we will throw in a runtime exception of uh i don't know saying some log let's say character id selected equals the character hiding so obviously this really isn't much of an exception here to find out a runtime exception but just to prove the point of you know what this user does at any point in the session we can go ahead and just log it here via the record exception and uh you know hopefully it's normally more of an error however we do need to actually crash this application somehow in order to see this opening up so maybe let's just go to the episode list fragment here and inside of our on view created at the bottom we will just crash the app okay so we have this up and running here if we go ahead and rerun this application we can see a handful of little exceptions or logs or something like that here and then we can actually go ahead and collect them here via the uh crashing the app and whatnot so if we click on rick sanchez we don't know what the idea is what we'll find out soon and then beth smith and then also summersmith and then we go to the episode list fragment and obviously the app is going to crash we have our four firebase uh log here sorry if you heard my cat in the background and then if we flip back over to the crashlytics here let's see how long it takes to kind of get this up and running all right so we actually i mean we did that in real time basically uh so we already have this information logged here so you can see that there is a crash um now there are a few different crashes here so now this dashboard is starting to come together here we have our event type here this one being non-fatal these other two being actual fatal crashes again stuff that we just hard coded and then you can see here in this little chart there's a difference between the fatal and non-fatal you can also go in through the event type filters here and just filter for the non-fatal ones and then it'll show you that since we don't have a whole lot i'm just going to leave the filter like no filter there and so we're just going to see everything at this point in time but if we go ahead and see this stuff here we can clearly see that there have been three non-fatal events for our one user we have the character id selected three and then here we can kind of page through the different events here so that we can see the character selected is four and then if we go to the first one it's going to be one with the rick sanchez information so that's wonderful here our logs still remain the same here right we just see the nav graph activity let's see if we bounce out to the other crash here on the episode list fragment let's see if these logs say anything different yeah so point being we basically go to the screen we basically go to the activity and then it gets logged you know at one time at one time only even though we navigated a few different ways before this crash happened in our episode list fragment we navigated around inside of our app we only get basically the activity because of you know how firebase is set up originally doesn't really work well with fragments however we can change that here so if we flip back over to our android studio we're going to leave this for now but a quick thing that i'm going to do here is search for the whole project for this exact string the colon fragment open bracket and basically that means uh that these four fragments here are our four fragments so what i'm thinking here is one thing we can do to accomplish you know logging which fragment we view is creating a base fragment that all these fragments extend and then in that on view created of the base fragment we can simply do our log and we can actually log the um you know the name of the class here so if we just go ahead and take a look here we'll just put it in the base package we're just going to call this base fragment here it's going to be a class it's going to extend the fragment the android x fragment here i believe all of mine take in the at layout res layout res and we'll just pass that in to the constructor of the fragment and then here in the on view created what we will do is simply log our information so we can say firebase crashlytics get instance of and i believe it's just going to be log let's go ahead and check the documentation here right so yes we're using record exception here and then otherwise we can use log at this point and then we kind of need to log something that is you know unique here or something that's helpful for us so we can say here sure let's uh let's give this a whirl with just our simple name here for now and if we need to change it we will but the one thing that we do need to change here actually is we do need to go ahead and change all of this around so again uh we are just going to change this to be the base fragment then we're going to go into this fragment as well and change it to be the base fragment we'll take the base fragment here okay so we'll just need to create uh we need to modify something here in the base fragment okay so now all of our fragments extend base fragment we do have a small issue here just because we need to simply just make that open or abstract or something that we can extend from it and that is about it so now all of our fragments here implement this fragment so that means that this onview created is going to run for all of our different fragments or different pages that we see so we are going to go ahead and log in the onview created the name and we should see a whole bunch more information helpful information inside of the logs here so if we go into the character details fragment for morty smith and then we bounce out and then we go in there for jerry smith and then we bounce out again and now we want to go to the episodes the app is going to crash which is wonderful because we do want to take a look at all this information here inside of our crashlytics so wonderful it has already been updated so that is fantastic uh let's find the correct one here yep sorry this is the correct one obviously we need to look at the crash here the episode list fragment crash and so we can see the time newest first here so that means that this one is the older version or this is the first thing the user did so they saw the character list fragment the screen view gets logged as well so that just must have happened uh very close to one another there then we see that we go to the character detail fragment then back to the list then to the detail then to the list again and then we go to the episode list and then our crash happens so with having this information stored in the or i guess logged inside of the base class that we had offered there we see that whenever any of these fragments are inflated or any of them are there on view created runs we do log this information to the crashlytics library so that when a crash does happen or if a crash does happen we will at least have a little bit of a breadcrumb a little bit of a trail here of what exactly happened what the user went through and you know this can hopefully help debug or recreate any of the issues that you have inside of your applications and so the last thing here that i did want to cover in this episode because we brought it up here we'll be reviewing the documentation is just the simple fact that it's quite simple to you know set the particular uh id here so we're just going to fudge this obviously but uh you know this would probably be helpful for we'll leave it at that but it'll it'll be helpful for when your user you know signs in or something along those lines you'll be able to you know set this unique identifier so that then this information will also be presented to you inside of the application so if we go to this page and we go back and then we go ahead and kill the app via the nice little setup we have there we can go ahead and take a look at our crashlytics and once we see here i gotta just find the right one here okay so it's gonna be this one and then the one that's most recent will come up first here it seems so we're gonna go ahead and just use that again we'll see in our logs we'll see the little breadcrumbs there and then in the data tab here we have it even knows it it adds like another little header another little section if you will here and it gives you the particular user id so you can also have this information when reviewing your crashes and your crash reports so that then you can you know kind of couple that with maybe the logs i'm sorry my cat is just screaming right behind me uh but you know with the little bread crumbs here and then you'll be able to get you know hopefully the full picture and diagnose whatever issue is going on there so this was a little bit of a more in-depth i guess analysis of what you can do in crashlytics and how you can customize your you know reporting here and all that kind of stuff you know again you can run through the different filters here so that it makes your life a little easier and as you start pushing out updates you can obviously you know see all of them or if you just want to see particular versions and see how the latest release is doing or something like that so crashlytics again there's really so much you can do inside of here it's honestly an absolute necessity if you're going to be pushing code to prod again i will link all the stuff in the description here so that you can review the documentation on your own time and please don't hesitate to reach out if you do have any questions this is something that's pretty important to get right so that you you know can kind of provide the users the best experience possible and you know kind of mitigate bugs and all those kind of issues as fast as possible just to keep your app up and running as smooth as possible so if you made it this far in the video i really appreciate a like i'd really appreciate a comment let me know how you're doing if you learned something if you think this is helpful or if you don't like crashlytics you know let's get the conversation going inside the comments it would be great uh if you do notice that you are not subscribed consider subscribing only because i am pushing out content on a pretty regular basis uh sometimes daily sometimes you know multiple times a week so there is plenty more content to come here we've just scratched the surface here really with firebase the project overview uh getting things set up and crashlytics there are all of these other tabs that you can just use to your advantage um and you know i mean there's just there's there's a lot to cover here so we might not get to it in this season but we will definitely get to it uh at some point here on the channel firebase really is just a blessing so with that in mind i'm gonna go ahead and cut this video here so i will catch you guys in the next one and have a good day thanks
Info
Channel: The Android Factory
Views: 9,569
Rating: undefined out of 5
Keywords: android, kotlin, firebase crashlytics, crash reporting, firebase crashlytics android, android firebase crashlytics, firebase crashlytics android tutorial, crashlytics, firebase, tutorial firebase crashlytics, crashlytics firebase android, crashlytics android, firebase in android, firebase android, android firebase, native crash reporting, crash reporting firebase, android crash reporting, firebase crashlytics for android, firebase crashlytics flutter, crashlytics android app
Id: JxVYfZprK0g
Channel Id: undefined
Length: 13min 23sec (803 seconds)
Published: Tue Jul 20 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.