Getting the crash log and send it as email

后端 未结 5 567
盖世英雄少女心
盖世英雄少女心 2021-02-06 13:23

From my search, i got the below code for getting the Crash Log .

try {
      Process process = Runtime.getRuntime().exec(\"logcat -d\");
      BufferedReader buf         


        
5条回答
  •  清酒与你
    2021-02-06 13:48

    I recommend you use ARCA https://github.com/ACRA/acra.

    Include arca in your build.gradle--it uses the apache 2.0 license as of 10/29.

    compile 'ch.acra:acra:4.9.0' //TODO:  Apache 2.0 license https://github.com/ACRA/acra
    

    In your class that extends Application, drop this on top of the "class" declaration.

    @ReportsCrashes(mailTo = "someone@somewhere.com",
            customReportContent = { ReportField.APP_VERSION_CODE, ReportField.APP_VERSION_NAME, ReportField.ANDROID_VERSION, ReportField.PHONE_MODEL, ReportField.CUSTOM_DATA, ReportField.STACK_TRACE, ReportField.LOGCAT },
            mode = ReportingInteractionMode.TOAST,
            resToastText = R.string.resToastText) //you get to define resToastText
    public class MyApplication extends Application {
    

    Then override the following method from the same Application class like so:

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
    
        // The following line triggers the initialization of ACRA
        ACRA.init(this);
    }
    

提交回复
热议问题