[Music]
hey thanks for tuning into this firecast
my name is Doug Stevenson and I'll show
you how you can get started monitoring
crashes in your Android app with
Firebase crash reporting imagine you've
spent a lot of time developing and
testing your Android app and you've just
published it to the Play Store for
everyone to use now obviously you want
your users to have the best possible
experience with your app so if there's a
bug that causes problems in it you need
to know that as soon as possible so you
can fix it to help with this you can
integrate the Firebase crash reporting
SDK with a single line of configuration
before you publish if you haven't
integrated any other Firebase features
in your app yet watch this other video
first to get started then you can follow
along here to use Firebase crash
reporting I already have an app that's
using Firebase so I'll integrate crash
reporting into that I'm going to open my
apps build.gradle and find the project
dependencies block then I'll add the
dependency for Firebase crash reporting
the latest version at the time of this
recording is
10.0.1 you should find and use the
latest version then I'll sync my project
and that's it adding the dependency is
all you have to do if you want to record
when your app crashes there are no
additional lines of code to write it
just works whenever an exception is
thrown that crashes your app you receive
that exception with its full stack Trace
in the Firebase console to improve on
that there are some additional things
you can do with a few lines of code
using the Firebase crash reporting API
for example you can log messages that
will appear in a crash report so you can
get some more context into what was
happening just before the crash and you
can report exceptions that you catch if
you don't know how to handle them these
will show up as non-fatal reports in the
console typically you don't need to
report Cod exceptions but it can be
useful for diagnosing rare or unexpected
problems I'll add some of these calls
right
now first I'll add a line of code to log
a message that I know will happen just
before I report an exception then I'll
report a fake exception that I'll create
on my own it works the same as if I had
caught the exception inside a tri catch
now I'll build and launch the app and
examine the log file if I want to see
the report for this I'll load up
Firebase console for my app and select
crash reporting on the left you can see
that the console for my app now shows my
exception as a non-fatal error that
didn't crash the app if I click into it
I can see details about the device in
this case we see it's from my emulator
the full stack Trace is also there in
addition to the message I logged after I
fixed the problem I can close this issue
with the close button so it won't show
again when a new crash is discovered by
Firebase crash reporting I'll also
receive an email notification this email
gives me some basic details about the
crash and a button to click to view it
in the
console it should take less than a
minute for a report to show up in the
console after it's sent when you're
trying this yourself be sure to have a
good network connection and also try
launching the application again to make
sure any unsent reports have a chance to
make it to the console a new app like
mine doesn't have very many interesting
crashes to view but you can use the
Firebase demo app to view much more
interesting data you can get readon
access to that project by using the link
in the description below the demo app is
called flood it by lab Pixies which is a
game that you can download from the Play
Store let's see what crash reports look
like for that app right
now this project has both an Android app
and an IOS app associated with it and
I'm going to choose to view the crashes
for the Android version here we can see
the recent history of crashes with
details in the table below sorted by the
number of times each has occurred if I
click one it will show me the stack
trace and if I click view details it
will show me some statistics about this
particular error notice that you can
view each and every occurrence of this
crash by clicking the arrows this entire
collection of crashes is called an issue
and an issue is formed based on crashes
that are similar to each other they all
represent the same error but the stack
trace and device details may be slightly
different from each other for an
individual crash you can see detailed
information about the device at the time
of the crash in this particular error
the most helpful part of the stack Trace
happens to be hidden so I'm going to
expand that here you can see that the
problem starts in the extra steps
activity and its on resume method if I
scroll down further I can see a log of
what happened just before the crash here
there are a bunch of log items that were
automatically created from Firebase
analytics events at the time they
occurred these events are logged
automatically you don't have to write
any code to make this happen
and that's a basic tour of Firebase
crash reporting but there's a few more
things you need to know before you
publish your app to the Play Store first
be sure to separate your development
environment from your production
environment the usual way to do that is
to create a whole new Firebase project
for each type of build that way any
crashes that occur while developing your
app will remain separate from those that
happen to your users in production you
can read this blog post to get more
information about that second if you're
using progard to obfuscate and shrink
your code you'll need to upload the
mappings file generated for the build
that you publish to the store you can
either upload it through the console or
use a Gradle plugin to run a task that
performs the upload be sure to read the
documentation about that because you
won't be able to read your stack traces
without uploading the correct mapping
file if you have any questions about
Firebase crash reporting reach out to us
on Twitter with the hash ask Firebase or
any of the Firebase support channels my
name is Doug Stevenson thanks for
watching and be sure to squash all those
bugs thanks for watching our video check
out some more here and don't forget to
subscribe to the Firebase YouTube
channel
[Music]