How to crash an Android app programmatically?

后端 未结 13 1734
遥遥无期
遥遥无期 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

    You could try a Null Pointer exception.

    Integer i = null;
    

    Then invoke any method on the object.

    i.byteValue();
    

    Invoking a method on an object that hasn't been initialized will crash the app.

提交回复
热议问题