55import com .github .mzule .activityrouter .annotation .Modules ;
66import com .guiying .common .base .BaseApplication ;
77
8+ import org .acra .ACRA ;
9+ import org .acra .ReportField ;
10+ import org .acra .ReportingInteractionMode ;
11+ import org .acra .annotation .ReportsCrashes ;
12+ import org .acra .collector .CrashReportData ;
13+ import org .acra .sender .EmailIntentSender ;
14+ import org .acra .sender .ReportSender ;
15+ import org .acra .sender .ReportSenderException ;
16+
817/**
918 * <p>这里是整个组件化项目管理各个组件的地方,所有需要使用的组件必须在此声明</p>
1019 *
1120 * @author 张华洋 2017/2/15 20:14
1221 * @version V1.2.0
1322 * @name MyApplication
1423 */
24+ @ ReportsCrashes (
25+ mailTo = "guiying705@Gmail.com" ,
26+ mode = ReportingInteractionMode .DIALOG ,
27+ customReportContent = {
28+ ReportField .APP_VERSION_NAME ,
29+ ReportField .ANDROID_VERSION ,
30+ ReportField .PHONE_MODEL ,
31+ ReportField .CUSTOM_DATA ,
32+ ReportField .BRAND ,
33+ ReportField .STACK_TRACE ,
34+ ReportField .LOGCAT ,
35+ ReportField .USER_COMMENT },
36+ resToastText = R .string .crash_toast_text ,
37+ resDialogText = R .string .crash_dialog_text ,
38+ resDialogTitle = R .string .crash_dialog_title )
1539@ Modules ({"app" , "main" , "girls" , "news" })
1640public class MyApplication extends BaseApplication {
1741
1842
1943 @ Override
2044 public void onCreate () {
2145 super .onCreate ();
46+ //崩溃日志记录初始化
47+ ACRA .init (this );
48+ ACRA .getErrorReporter ().removeAllReportSenders ();
49+ ACRA .getErrorReporter ().setReportSender (new CrashReportSender ());
2250 }
2351
2452 @ Override
@@ -27,4 +55,22 @@ protected void attachBaseContext(Context base) {
2755 // dex突破65535的限制
2856 //MultiDex.install(this);
2957 }
58+
59+
60+ /**
61+ * 发送崩溃日志
62+ */
63+ private class CrashReportSender implements ReportSender {
64+ CrashReportSender () {
65+ ACRA .getErrorReporter ().putCustomData ("PLATFORM" , "ANDROID" );
66+ ACRA .getErrorReporter ().putCustomData ("BUILD_ID" , android .os .Build .ID );
67+ ACRA .getErrorReporter ().putCustomData ("DEVICE_NAME" , android .os .Build .PRODUCT );
68+ }
69+
70+ @ Override
71+ public void send (Context context , CrashReportData crashReportData ) throws ReportSenderException {
72+ EmailIntentSender emailSender = new EmailIntentSender (getApplicationContext ());
73+ emailSender .send (context , crashReportData );
74+ }
75+ }
3076}
0 commit comments