Android ACRA不创建报告
我已经在我的应用程序中实现了ACRA 4.8.5,它已初始化并启用,但当我遇到错误时,它不会创建报告。。。我仅有的两个相关ACRA日志是:Android ACRA不创建报告,android,report,acra,Android,Report,Acra,我已经在我的应用程序中实现了ACRA 4.8.5,它已初始化并启用,但当我遇到错误时,它不会创建报告。。。我仅有的两个相关ACRA日志是: I/ACRA: ACRA is enabled for com.mydomain.myapp, initializing... 及 我的申请课上有这个 @ReportsCrashes(reportSenderFactoryClasses = {ACRASenderFactory.class}) 及 这是我的ACRASenderFactory课程 publ
I/ACRA: ACRA is enabled for com.mydomain.myapp, initializing...
及
我的申请课上有这个
@ReportsCrashes(reportSenderFactoryClasses = {ACRASenderFactory.class})
及
这是我的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();
}
}
这是我的AcarReportSender类
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[] = {"me@mydomain.com"};
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();
}
}
我真的不知道为什么它不起作用。。我还允许在我的清单中使用Internet并设置我的应用程序名
任何帮助都将不胜感激!
谢谢 我的问题(我想)是我正在为API 15及更高版本开发。使用ACRA 4.8.5可能是个问题,因为使用ACRA 4.7.0效果很好 正如关于ACRA GitHub问题的讨论,ACRA已经作为AAR发布了一段时间了。因此,您需要构建并包括AAR,而不是JAR(您必须从AAR中挖掘出来) ACRA需要Android服务和资源才能运行
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();
}
}
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[] = {"me@mydomain.com"};
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();
}
}