I don’t know about you but I feel very embarrassed when I deliver an app to tester or client for testing and it get crash. That moment is very painful for me.
I personally don’t like that crash alert dialog that appears when my app gets crash. So I found an interesting library that will show an error screen instead of an error dialog.
Let’s get started.
What I’m going to use:
- Android Studio
After creating a new project add this dependency in your
I am making my custom crash layout. Like this:
I downloaded this error image from here.
Let’s do some coding part to catch the crash event and show custom screen instead of android default dialog.
Now you need to make an application class that will register in the android manifest to register crash library globally in-app.
Add this class in
Now moving towards
MainActivity.kt to see this in action. We need to crash our app to see the crash screen. I am implementing a crashing code in my
var array = mutableListOf<String>() array = "Hello" findViewById<TextView>(R.id.textView).text = array
This will crash my app as this code will generate
Let’s run the app.
Download Source code from here.