How to crash an Android app programmatically?

后端 未结 13 1490
遥遥无期
遥遥无期 2021-02-05 00:37

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?

13条回答
  •  执念已碎
    2021-02-05 01:01

    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!

提交回复
热议问题