我已經在我的應用程序中實現了ACRA 4.8.5,並且它已被初始化並啓用,但是當我面對一個錯誤時,它不會創建報告...唯一兩個相關的ACRA日誌I有【ACRA沒有創建報告
I/ACRA: ACRA is enabled for com.mydomain.myapp, initializing...
和
E/ACRA: ACRA caught a RuntimeException for com.mydomain.myapp
我有這個在我的應用程序類
@ReportsCrashes(reportSenderFactoryClasses = {ACRASenderFactory.class})
和
@Override
public void onCreate() {
super.onCreate();
ACRA.init(this);
}
這裏是我ACRASenderFactory類
public class ACRASenderFactory implements ReportSenderFactory {
public ACRASenderFactory(){
Log.e("ACRA", "Create Sender Factory");
}
@NonNull
@Override
public ReportSender create(Context context, ACRAConfiguration acraConfiguration) {
Log.e("ACRA", "Return Report Sender");
return new ACRAReportSender();
}
}
,這裏是我的ACRAReportSender類
public class ACRAReportSender implements ReportSender {
public ACRAReportSender(){
Log.e("ACRA", "Report Sender created");
}
@Override
public void send(Context context, CrashReportData crashReportData) throws ReportSenderException {
Log.e("ACRA", "Trying to send crash report");
String reportBody = createCrashReport(crashReportData);
// Send body using email
Intent emailIntent = new Intent(Intent.ACTION_SEND);
// Set type to "email"
emailIntent.setType("vnd.android.cursor.dir/email");
String to[] = {"[email protected]"};
emailIntent.putExtra(Intent.EXTRA_EMAIL, to);
// Text
emailIntent.putExtra(Intent.EXTRA_TEXT, reportBody);
// Set the subject
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "ACRA Crash Report");
context.startActivity(Intent.createChooser(emailIntent, "Send crash to developpers by email ..."));
}
private String createCrashReport(CrashReportData crashReportData){
StringBuilder body = new StringBuilder();
body.append("Device : " + crashReportData.getProperty(ReportField.BRAND) + " - " + crashReportData.getProperty(ReportField.PHONE_MODEL))
.append("\n")
.append("Android Version : " + crashReportData.getProperty(ReportField.ANDROID_VERSION))
.append("\n")
.append("App Version : " + crashReportData.getProperty(ReportField.APP_VERSION_CODE))
.append("\n")
.append("STACK TRACE : \n" + crashReportData.getProperty(ReportField.STACK_TRACE));
return body.toString();
}
}
我真的不知道爲什麼它不工作。我已允許互聯網我的Manifest並設置我的應用程序名稱。
任何幫助將非常感謝! 謝謝!