Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to crash an Android app programmatically?

I want to test out crash report using acra but the first step is I need to simulate a fatal crash in Android using code.

Any idea?

like image 968
Howard Avatar asked Aug 04 '12 09:08

Howard


People also ask

Does Android have a crash log?

Select an app. On the left menu, select Quality > Android vitals > Crashes and ANRs. Near the center of your screen, use the filters to help you find and diagnose issues. Alternatively, select a cluster to get more details about a specific crash or ANR error.

What causes app crashes on Android?

Apps on Android can crash because of low storage space, too many apps running simultaneously, a weak internet connection, or not having the proper app updates installed.


2 Answers

Just execute this code: divide by zero 

Update: Also can try this Create a method,

public void stackOverflow() {         this.stackOverflow();      } 

And call this somewhere/buttonClick

OR simply throw an uncaught exception

throw new RuntimeException("This is a crash"); 

Bingo!

like image 150
Vineet Shukla Avatar answered Oct 18 '22 20:10

Vineet Shukla


  1. Access a view that is not defined.
  2. Access the first element of an empty list without checking.
  3. Divide by Zero.
  4. Throw the device out the window.
  5. Submerge the device in water.
like image 22
JoxTraex Avatar answered Oct 18 '22 19:10

JoxTraex