how to force to crash firebasecrashlytics?

Viewed 4766

I am developing news app and I am new to firebase Crashlytics I want to force to crash and I want to get a report of the crash but I am not getting any crash reports how can I achieve that

below my Implementation

binding.root.setOnClickListener { v ->

                FirebaseCrashlytics.getInstance()

                val intent = Intent(v.context, DetailActivity::class.java)
                intent.putExtra(urlKey, articleList[position].url)

                v.context.startActivity(intent)
            }

below my firebase crashlytics console screenshot my firebasecrashlytics console

I want to know where I am making mistake how can I force to crash my app

4 Answers

how can I force to crash my app

Just throw an exception that gets handled by crashlytics unhandled exception handler, e.g.

throw RuntimeException("crash testing")

You can try this:

binding.root.setOnClickListener { v ->
       val intent = Intent(v.context, DetailActivity::class.java)
       intent.putExtra(urlKey, articleList[articleList.size].url) // you can throw ArrayIndexOutOfBoundsException

       v.context.startActivity(intent)
}

or

binding.root.setOnClickListener { v ->
         throw RuntimeException("Test Crash") // Force a crash
}

You can do it like this inside the onCreate function:

in Kotlin: throw RuntimeException("Test Crash")

in Java: throw new RuntimeException("Test Crash");

What about simply calling

FirebaseCrashlytics.getInstance().recordException(Exception("My test exception"))
Related