how to force to crash firebasecrashlytics?
Asked Answered
P

4

5

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

Primatology answered 29/5, 2020 at 8:19 Comment(2)
did you follow the documentation to implement crashlytics ?Andorra
Have you followed the tutorial? What you are asking is literally the second step of the getting started guide, here: firebase.google.com/docs/crashlytics/…Runyon
J
6

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")
Jacquelyn answered 29/5, 2020 at 8:20 Comment(2)
Wherever you want to have your crash. For example a click listener of a "crash me" button.Jacquelyn
but now I have implemented databinding in adapter class in the example they have tested when user clicks button but there is not button in my adapter classPrimatology
J
1

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
}
Jules answered 29/5, 2020 at 8:28 Comment(11)
I have tried your solution but firebase not detecting crashesPrimatology
Did you complete to implement?Microelectronics
it is not detectedPrimatology
Abi nasilsin benda turk erurPrimatology
Selam Edgar, Adım adım dokümanı takip etmelisin. Başaralı bir şekilde kurulumu yaparsan, hata raporlarını görebilirsin. (Hi Edgar, you should follow the docs. step by step. If you successfully complete to implement, you can see the crash reports)Microelectronics
I followed documentation I have done exactly what said there but it is not showing nothingPrimatology
Could you share Firebase Console -> Crashlytics screen-shotMicroelectronics
Hi I have added screenshot to post please check itPrimatology
You didn't complete to add the sdk. If you added the sdk, uninstall and reinstall your app.Microelectronics
I have checked by filtering firebase there is showing that firebase crashlytics installed in android studio I forced crashed as you told me but crashlytics console showing nothignPrimatology
It may take some time. I edited my answer. You can try this.Microelectronics
M
0

You can do it like this inside the onCreate function:

in Kotlin: throw RuntimeException("Test Crash")

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

Morality answered 11/8, 2021 at 17:52 Comment(0)
R
0

What about simply calling

FirebaseCrashlytics.getInstance().recordException(Exception("My test exception"))
Repentant answered 12/5, 2022 at 22:6 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.