How to get Android crash logs?

前端 未结 17 1386
余生分开走
余生分开走 2020-11-28 18:07

I have an app that is not in the market place (signed with a debug certificate), but would like to get crash log data, whenever my application crashes. Where can I find a lo

17条回答
  •  迷失自我
    2020-11-28 18:39

    Base on this POST, use this class as replacement of "TopExceptionHandler"

    class TopExceptionHandler implements Thread.UncaughtExceptionHandler {
    private Thread.UncaughtExceptionHandler defaultUEH;
    private Activity app = null;
    private String line;
    
    public TopExceptionHandler(Activity app) {
        this.defaultUEH = Thread.getDefaultUncaughtExceptionHandler();
        this.app = app;
    }
    
    public void uncaughtException(Thread t, Throwable e) {
    
    
    
    
        StackTraceElement[] arr = e.getStackTrace();
        String report = e.toString()+"\n\n";
        report += "--------- Stack trace ---------\n\n";
        for (int i=0; i

    }

    .....

    in same java class file (Activity) .....

    Public class MainActivity.....
    

    .....

     @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Thread.setDefaultUncaughtExceptionHandler(new TopExceptionHandler(this));
    

    .....

提交回复
热议问题