'how to force to crash firebasecrashlytics?
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
Solution 1:[1]
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")
Solution 2:[2]
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
}
Solution 3:[3]
You can do it like this inside the onCreate function:
in Kotlin: throw RuntimeException("Test Crash")
in Java: throw new RuntimeException("Test Crash");
Solution 4:[4]
What about simply calling
FirebaseCrashlytics.getInstance().recordException(Exception("My test exception"))
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | laalto |
| Solution 2 | |
| Solution 3 | Halil Ozel |
| Solution 4 |
